Does HTTP PATCH
method restrict updates to only one field at a time? Can I modify more than one field in a PATCH
request? Can PATCH
be used for modifying all the fields?
Does HTTP
PATCH
method restrict updates to only one field at a time?
No.
Can I modify more than one field in a
PATCH
request?
Of course.
Can
PATCH
be used for modifying all the fields?
Yes. But you may consider PUT
for that purpose. And, depending on your needs, you may consider supporting PATCH
along with PUT
in your API.
The PATCH
method definition doesn’t enforce any format for the request payload apart from mentioning that the request payload should contain a set of instructions describing how the resource will be modified and that set of instructions is identified by a media type (which defines how the PATCH
should be applied by the server).
From the RFC 5789:
The
PATCH
method requests that a set of changes described in the request entity be applied to the resource identified by the Request-URI. The set of changes is represented in a format called a “patch document” identified by a media type. […]
Some suitable formats for describing such set of changes are:
application/json-patch+json
)application/merge-patch+json
)I've added more details about each of these formats in this answer along with a comparison with PUT
. So I strongly encourage you to have a look.