Idempotent vs Safe HTTP Methods
Hello, was just reading a bit about HTTP Methods. From what I've understood, a safe HTTP request/method is one that doesn't change anything. For example a
GET
will only retrieve information without changing their values. Similarly, the OPTIONS
http method creates a request that ask the server what the client is allowed to do (used in preflight CORS
).
Now, idempotent means one that has no side effects. That is, it's a method that will always produce the same result. Here is where I have some confusion, when we talk about idempotent in this case, we are talking about how the values are sent?9 Replies
idempotent really just means "same input == same output". This is about REST APIs, usually. Basically when you send a request to a server, it doesn't matter how often it's sent, it always produces the same results.
when we say it always produces the same results, this mean something that happens on the back-end side?
I mean for e.g if a user send a POST request to create an order, the order will get an order id of say 001. If he sends the same request, he will get another order id, say 002.
This differs back-end side, like we don't store the same thing twice since the id is unique.
However, client-side, on the UI, the same thing is displayed twice maybe
no, that's not it. If you send a POST, and get a new ID back, you've created a second record in the database with a new ID. That is not idempotent
POST (create) actions aren't usually idempotent
https://restfulapi.net/idempotent-rest-apis/ there's a lot of good info here
REST API Tutorial
Idempotency - What is an Idempotent REST API?
A REST API is called idempotent when making multiple identical requests to an API has the same effect as making a single request.
yep I see
will have a look, thanks !
by the way idempotent and safe, is it just theoretical stuff what someone should know or it does have some importance?
ah ok just reading the article
yeah I guess they have their importance

most theoretical stuff is important
yup noted
this is very important