Designing an API, we've come up against the question of whether a PUT payload should contain the ID of the resource being updated.
This is what we currently have:
PUT /users/123 Payload: {name: "Adrian"}
Our route code extracts the ID from the URI and continues on with the update.
The first users of our API are questioning why we don't allow ID in the payload:
PUT /users/123 Payload: {id: 123, name: "Adrian"}
The reason we didn't allow it is because the ID is duplicated, in the payload and URI.
Thinking about this some more, we are coupling the resource to the URI.
If the URI doesn't have the ID, the payload will need to be amended:
PUT /no/id/here Payload: {name: "Adrian"} < What user???
Are there any reasons not to?