Reputation: 3013
Can you please provide an example of a RESTful API call (using HTTP protocol) which is non-idempotent and safe, at the same time (does something like that even exist)?
To elaborate a little bit on this, while reading about the Hypermedia-Oriented Design, I've encountered the 4 affordance aspects that describe each transition: safety, idempotence, mutability and transclusion. Also, I've encountered a table which describes the HTTP verbs through those aspects and it goes like this:
---------------------------------
HTTP Method Idempotent Safe
---------------------------------
OPTIONS yes yes
GET yes yes
HEAD yes yes
PUT yes no
POST no no
DELETE yes no
PATCH no no
---------------------------------
My intuition tells me that all of the safe methods are automatically idempotent too (but not vice versa). I would just like to either confirm or refute this once and for all.
Thanks in advance for the answers.
Upvotes: 1
Views: 97
Reputation: 3799
Yes. All safe methods are also idempotent, but they refer to two different (but related) qualities of a RESTful API.
A safe method call (one which does not modify the state of the resource on the server) may be issued multiple times by the client without affecting the state of the server (the definition of idempotency).
Upvotes: 1
Reputation: 66292
A safe method - one that does not modify anything - is by definition idempotent. Since it has not changed anything, it will have the same effect (that is, no effect whatsoever) no matter how many times you call it.
Upvotes: 1