Retry on HTTP 4xx Errors
How to configure outbound stages to retry a remote service call when an HTTP 4xx response matches specific error details.
There are a number of outbound stages in Integration Hub, which result in a call to a remote service that can return an HTTP 4xx error code:
- Outbound Dataverse Stage
- Outbound Form Data Stage
- Outbound Proxy API Stage
- Outbound Proxy API Store Response Stage
- Outbound Proxy API Store Response Binary Stage
- Webhook Push Alerts for Cosmos DB Stage
All of these stages support the same options for performing a retry of the remote service call when an HTTP 4xx error is received and specific error code and/or error message details appear in the response payload from the remote service.
From time to time, remote systems may be encountered which do not return the "correct" HTTP response code that aligns with what has occurred - for example, systems that return an HTTP 4xx error when the remote system is busy (instead of returning an HTTP 503 error, which would be more appropriate for the situation).
In these situations, it may be desirable to check the details of the payload returned with the HTTP 4xx error (if possible), to see if the situation warrants retrying the call to the remote system.
Use of this feature requires that the HTTP 4xx response returned by the remote system be a JSON-based payload.
"retryOn4xx": {
"errorCodePath": "error.code",
"errorMessagePath": "error.message",
"errors": [
{
"errorCode": "Code_1",
"errorMessage": "Message 1."
},
{
"errorCode": "Code_2",
},
{
"errorMessage": "Message 2."
}
]
}
The errorCodePath value is a JSON path definition which defines where in the JSON-based response payload an error code can be found, and the errorMessagePath value is a JSON path definition which defines where in the JSON-based response payload an error message can be found. Both of these fields are mandatory.
The mandatory errors array must contain at least one error code/error message object, and each of the supplied objects in the array must contain either an errorCode or an errorMessage value, or both.
When defined, if the remote system responds with an HTTP 4xx code, Integration Hub will use the errorCodePath and errorMessagePath values to obtain an error code and error message from the remote system response payload.
It will then attempt to match the error code and error message found in the remote system response payload against the defined objects of the errors array:
- If the object being evaluated from the
errorsarray only has an error code, then it will only attempt to match the error code found in the remote system response payload. - If the object being evaluated from the
errorsarray only has an error message, then it will only attempt to match the error message found in the remote system response payload. - If the object being evaluated from the
errorsarray has both an error code and an error message, then it will attempt to match both the error code and the error message found in the remote system response payload.
Matching of an errorCode value is based on a full string match, while matching of an errorMessage value is based on a substring match (i.e. is the defined error message from the object in the errors array a substring of the error message from the remote system response payload).
In the event that a matching object from the errors array is found, testing will halt, and the stage will retry the remote system call.
Last updated on