So you can do: POST to create, then PATCH to update 1 field
Or: PUT to create if row not there, but update existing row if it is there. You must pass in all the fields needed for a POST plus the uuid of the row.
Or: PATCH with the uuid of the row and just a one or two fields you want to update but not 100% of the fields.
But in most API's I've worked on they ignore PATCH, have no upsert ability, and make PUT update just a few fields.
How do we feel about this? Keep using PUT this way since it's so common or fight and good fight and use the 3 combo POST,PUT,PATCH?
> POST > The POST method submits an entity to the specified resource, often causing a change in state or side effects on the server.
> PUT > The PUT method replaces all current representations of the target resource with the request payload.
> PATCH > The PATCH method applies partial modifications to a resource.
The Mozilla documentation further differentiates POST and PUT with respect to idempotency. To wit:
> The difference between PUT and POST is that PUT is idempotent: calling it once or several times successively has the same effect (that is no side effect), whereas successive identical POST requests may have additional effects, akin to placing an order several times.
So just to summarize: PUT is idempotent replacement, POST is potentially not-idempotent change, and PATCH is a partial update.
There's nothing in the spec that says POST = create and PUT = update. Instead, it describes different idempotency restrictions.
I know it doesn't exactly answer your question, exactly, but this is what the "official" definitions are.
[0]https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods