3 ms·
> What happens if the response from your server to mine is lost after you've already committed the change; is there an idempotent way I can verify what happened
by tadfisher 14y ago
> What happens if the response from your server to mine is lost after you've already committed the change; is there an idempotent way I can verify what happened?
What is the "right way" to handle this? Say I'm building a REST API, and a user POSTs to a collection, which returns the URL to the posted resource in the Location header. POST in this case isn't idempotent, so what mechanism can I provide for the user to check that this resource was indeed created? A search method?
- saurik 14y agoI am not certain I know the "right way" to deal with this, but a common way that makes my life as a consumer of APIs much easier is to make the API idempotent (if I pass the same request, including a nonce, I get back the exact same result as the earlier request). There are other solutions, though; I will claim that most of them that I have seen, however, involve making the client much more complex (such as a search system, unless the search system allows me to search by the nonce; an example of doing the search solution reasonably is Amazon Payments, and an example of doing the idempotent API reasonably is PayPal v74.0+). (BTW: the possibly short snippet for my long post might me "API semantics that make it impossible to build a completely automated solution even in the case of failures, either transient or persistent".)