How to Handle an External API Call Error in Workflows
Last Updated:
Overview
Applies To
Solution
The card has two sections Try and If Error.
In the Try section, place the API Connector card followed by any other logic. In this example, there is a single Assign card to create a success message. The other cards can be added as well. The message is then mapped to the If Error card’s output.
If Error card – success section
In the If/Else section, there is a default error message followed by any other logic. In this example, it’s again a single Assign card that holds the error message. The message is then mapped to the If Error card’s output.
If Error card – error section
After the If Error card, add additional logic. Here is an example of sending a success or an error message to the Compose card.
Now, test the flow. The flow uses a service called mock.codes. mock.codes provide an easy way to reference and test HTTP responses.
Running the flow with HTTP response 200 (https://mock.codes/200) that results in success:
Running the flow with HTTP response 500 (https://mock.codes/500) that results in Internal Server Error:
The flow chart helps visualize the flow logic at a high level:
