We’re currently using the HTTP Connector to make requests to an API, and we’d like to implement retry logic based on the API’s response. Specifically, we want to retry the request if we receive a 500 Internal Server Error.
We noticed that the retry count
parameter in the connector doesn’t seem to handle this case — it only retries on failed calls, not on specific response codes like 500.
What’s the recommended way to implement retries based on HTTP response codes?
You’re correct — the retry count
in the HTTP Connector does not evaluate the HTTP response code. It only retries when a call outright fails (e.g., network failure), and not when the API returns a 500 or similar response.
To implement retries based on the response code, you’ll need to add custom logic using the Loop component. Here’s a common pattern:
- Use the HTTPConnector to make the API call.
- Use the Loop component to evaluate the response code. For example:
- Retry if the response code is
500
- Limit to a maximum of 5 attempts
- Add a Sleep component (e.g., 5 seconds) between retries to avoid putting excessive load on the API.
We’ve attached an example graph demonstrating this setup.
For more information, check out the Loop component documentation.
HTTPconnector_Loop.grf (4.0 KB)