Sobes.tech
Junior — Middle

Can the PATCH HTTP method be used to update objects of different types in a single request?

sobes.tech AI

Answer from AI

The HTTP PATCH method is intended for partial updates of a resource. According to the specification, PATCH is applied to a single resource identified by a URI. Typically, a PATCH request updates one object.

If you need to update objects of different types in a single request, this is not standard practice and can lead to ambiguity and processing issues.

To update multiple objects of different types, it is better to:

  • Use multiple separate PATCH requests
  • Create a special API endpoint that accepts a batch of changes and processes them on the server

Therefore, using PATCH to update different objects in a single request is not recommended.