Should the PATCH method return all fields of the resource in the response body?

Normally this should be handled through content negotiation. In other words, the client asks for a specific representation if it needs one. The request would look like this:

PATCH /user/123
Content-Type: application/merge-patch+json
Accept: application/vnd.company.user+json
...

In this case, the client expresses that it wants a full user representation as answer. Or it could do:

PATCH /user/123
Content-Type: application/merge-patch+json
Accept: application/vnd.company.object-fragment+json
...

to ask for a generic fragment representation of some object.

You don’t have to implement both if you don’t want to, in which case you just do your use-case and respond with 406 Not Acceptable to media-types you do not support for the moment.

Leave a Comment