How to handle retries
POST methods are by their nature not idempotent calls, but given the chaotic nature of networks, there is a need to support the ability to retry POST calls if a response is not received. The problem with this is the server may have received the POST and processed the request, but for some reason, the client never received an acknowledgment.
TOTUS supports making POST methods idempotent by using the request-id field in the headers. By using specific values as described below, you can safely make multiple POST calls and receive an idempotent response.
How to define the request-id
Making the initial call
When first attempting a POST, there should be a unique requestid (we recommend using a UUID formatted as a plain string).
requestid: f938253a4c9d4ded89fe7265f72b1609
Calling after a timeout or no-response
f you do not receive a response from the server, it is safe to make another POST call with the same requestid. This will tell the server this is another attempt and not create duplicate data if the previous request was already processed.
If the server processes the initial POST, the original response will be returned in the new POST call. This allows the client to safely retrieve the results. You can continue making new POST calls with the same request id safely until you get a response.
Updated over 2 years ago