3 ms·
The idempotency in REST is about the State Transfer, not the state itself. The POST is not idempotent because it transferred a change of state (of the button)
by rswail 8y ago
The idempotency in REST is about the State Transfer, not the state itself.
The POST is not idempotent because it transferred a change of state (of the button) between the client and the server. REST is about State Transfer between a client and server.
POST/DELETE send a change of state of a resource.
GET/HEAD/OPTIONS do not.
PUT and PATCH are idempotent iff the server does not change the state of the resource except as the result of the PUT or PATCH.
It is not about the state of a resource on either the client or server, both are free to change that state independently.
Doing a GET on the current state of the button is idempotent because the client doesn't change the state of the button.
But there's nothing to stop the server (ie the elevator electronics) to change the state of the button (show it as "pressed") if something else changes the state (eg, someone in the elevator presses the button for that floor, the button might display as "pressed" on the floor itself).
- mateo411 8y agoI think that DELETE is also idempotent. When you call DELETE you are deleting a specific resource. The result is the same if you call DELETE more than once, the resource no longer exists.