This is a PUT vs PATCH question. The question title in other words: Normally, a URL of an underlying object exists at /object/{id}
. Is it still idempotent to add a URL /object/{id}/member
and call PUT on that specific member?
Minimal Example
If I have resource called Booking
that looks like this
public class Booking {
private bookingId;
private name;
}
//accessors ...
I think the PUT and PATCH stuff is clear. My confusion stems from deciding on what idempotency refers to...
- idempotency of response to a given URL? OPTION 1
- idempotency of the underlying data objects (Java) as opposed to members? OPTION 2
If the first case is true, then I would expect that it is RESTful to create a specific call to an object member of Booking like this:
PUT /booking/{id}/name
GRAY AREA HERE? (NORMALLY A PATCH OP AT booking/{id}
)
{
name: "Joe Schmoe"
}
In this case, the underlying object has been changed, but the resource remains idempotent (GET here would return the same and subsequent PUTs like above would not change anything), because the resource is specific to an object member? Or by altering a member, did I break the idempotency law?
If the second option is true, and URLs should not be made specific to object members, then I would expect to use PATCH on a member at a URL resource that represents the entire object to update specific object members like this:
PATCH /booking/{id}
*
{
name: "Joe Schmoe"
}
I expect that it is NOT RESTful to do the following. It would clearly break idempotency at of the resource URL. Let me know if I am mistaken here.
PUT /booking/{id}
{
name: "Joe Schmoe"
}