After a long, long time, the HTTP PATCH verb has become an official standard: IETF RFC 5789. From the abstract:
Several applications extending the Hypertext Transfer Protocol (HTTP) require a feature to do partial resource modification. The existing HTTP PUT method only allows a complete replacement of a document. This proposal adds a new HTTP method, PATCH, to modify an existing HTTP resource.
That's pretty great news, even though it will probably take some time before you can actually gain much of a benefit from it. Until now, there were two options of dealing with resource creation (and update, for that matter):
- Use a POST to create a new resource when you want the server to determine the URI of the new resource
- Use a PUT to do a full update of a resource (or create if it's not there already)
Sometimes, though, what you're looking for is a partial update. You have a bunch of different choices: You can design overlapping resources so that one of them reflects the part you're interested in, and do a PUT on that; or you can use POST, which is so unrestricted it can essentially mean anything.
With PATCH, you have a standardized protocol-level verb that expresses the intent of a partial update. That's nice, but its success depends on two factors:
- The availability of standardized patch formats that can be re-used independently of the application
- The support for the verb in terms of infrastructure, specifically intermediaries and programming toolkits
In any case, I will definitely start advocating its use for the purpose it's been intended to support, even if this means going with home-grown patch formats for some time: It's still better than POST, and using some sort of
x-http-method-override-style workaround should work nicely if needed.
Kudos to James Snell for investing the time and energy to take this up.