I try to implement a REST API following the json:api spec, but I am a bit confused.
In the “Updating Resources” section, the spec (v1.0) states that the …
resource can be updated by sending a PATCH request to the URL that represents the resource.
and
The PATCH request MUST include a single resource object as primary data. The resource object MUST contain type and id members.
A REST API would define PATCH /{resource}/{id}
, just like it was done in the example in that section.
That begs the question why the id has to be provided as a parameter, when it is already available per URL. What if the IDs in the URL and in the parameter differ? Surely they must (as in MUST) always be equal?
I suppose non-REST APIs shall be possible, to, but as far as I can see, I would much prefer if ID could be optional.
Many thanks for the feedback!
Update: The DELETE call, on the other hand, seems to be fine without any further parameters, just DELETE /{resource}/{id}