PUT /users/u/goals/g.json should really be PATCH

I’m not saying there should not be a PUT endpoint, too. I’m just saying the current endpoint pretends to PUT but doesn’t actually PUT. It PATCHes and that’s wrong, confusing and not restful.

Yes and no. PATCH is rather flexible and indeed as you point out, as long as what you are sending is describing changes, some kind of update instructions, you’re fine. There are actually two RFCs, that show how such update instructions could look like: The older and more complex RFC 6902 and the newer and simpler RFC 7396, also known as JSON Merge Patch, which is essentially what the API is doing right now: Only sending the changed fields with their new values. Just as a proper body and not as form parameters. You can read more about both methods in this wonderfully written article:

So, as an example, the body could look like this:

{
  "title": "Work Out Even More",
  "secret": "true"
}

Which is a very simple format. It’s literally a subset of the resource that is to be updated.

1 Like