Repeatable Requests for REST APIs
Everyone is using REST APIs nowadays, despite the fact that HTTP is an inherently unreliable protocol. So how to deal with “lost requests” and “lost responses”? Not a problem for GET requests: just repeat them if you get no answer – GET is “safe” and should not have side-effects.
Not so easy for POST, which is typically used to create something, or to trigger an action: you might end up with more than you wanted:
To solve this problem the SOAP world introduced WS-RM, RM meaning Reliable Messaging. As with many things in the SOAP world this specification slightly overdid it, providing
- At least once
- At most once
- Exactly once (the combination of 1 and 2), and
- In order
Number 4 is the tricky part, and it is actually often not needed.
So here’s a light-weight subset, just providing 1 and 2 (and thus 3), and avoiding the tricky bit: Repeatable Requests for REST APIs.
This mechanism can easily be combined with any REST dialect or flavor because it only relies on sending some additional headers – nothing OData-specific in it, despite being provided by the OASIS OData Technical Committee.
An early version of this mechanism, called Idempotent Services, is available in SAP Netweaver Gateway for OData V2 since 2013.
So problem solved – again 🙂