I know that PUT is idempotent but how Can I ensure it programatically? What conditions I must meet to create fully idempotent endpoint ?
From a RESTful service standpoint, for an operation (or service call) to be idempotent, clients can make that same call repeatedly while producing the same result. In other words, making multiple identical requests has the same effect as making a single request. Note that while idempotent operations produce the same result on the server (no side effects), the response itself may not be the same (e.g. a resource's state may change between requests).
A PUT
is supposed to update a resource with new values received in the request body. Therefore, whether it's sent just once or a couple of times, the result on the server shouldn't change (unlike a POST
, for example, where more requests will result in either a conflict error or in multiple resources created).