Can i use query parameters in http PATCH method in my Rest API, instead of sending a partial request body?
I want to avoid the overhead of maintaining the request class in the sender and receiver.
I want to update only 1 field.
Can i use query parameters in http PATCH method in my Rest API, instead of sending a partial request body?
I want to avoid the overhead of maintaining the request class in the sender and receiver.
I want to update only 1 field.
Can i use query parameters in http PATCH method in my Rest API, instead of sending a partial request body?
Yes, but probably not the way that you mean.
PATCH /a?b=c HTTP/2.0 Content-Type: application/merge-patch+json { "y": "z"} is a perfectly satisfactory HTTP request. It says "find the document identified by /a?b=c, and to that document apply the merge-patch as specified by RFC 7386."
Note carefully: the "query parameters" here are part of the identification of which document the patch should be applied to, and do not in any way describe the patch that should be applied.
What you should not be doing:
PATCH /a?b=c as an attempt to modify /a by updating "b" to the value "c". The fundamental problem here is that you are creating a new meaning for a request that has a standardized meaning, and therefore there is likely to be confusion when somebody tries to access your API using a general-purpose component.
In a situation where your API is only used by front ends that you control (for example, only called via your java script client downloaded from your web servers), and if you don't need to use any intermediate components (like a web cache) in the middle, then you might get away with it.
If you review HTTP cache invalidation, you will see that PATCH /a?b=c does not invalidate cached representations fetched via GET /a, because the target-uri do not match.
The answer appears to be no.
From the RFC, (emphasis mine)
The PATCH method requests that a set of changes described in the request entity be applied to the resource...
From Mozilla,
Request has body: Yes
One more corroborating reference, W3 PATCH, mentions the necessity of a Content-Length header.