As you can see in the image above you will now get the following additional fields you can use in your logic and workflows…
Error Status Code. What status coded the API return. 200 is OK etc…
Error Status Message. What was the error message returned from the API, if any.
Error Body. This is where you usually get the biggest clues on why your API request failed. This should tell you the exact problem and what you need to fix.
Returned an Error. This gives you a boolean YES or NO value you can use in your workflow’s logic to decide to do different things depending on whether the API call failed or not.
Once you’ve got this all set up, we can start updating our workflows with logic on what to do when an API call fails.
Handling API Errors in your Workflows.
So when a workflow runs and uses an external API, we might want to do some different things depending on whether an API call fails.
To give you an example of this, I’m going to show what my app does when my app makes a request to update an order’s note on Shopify.
This happens whenever a new feedback message is left - my app goes to Shopify’s API and attempts to add that feedback to the order’s notes.
Sometimes these API calls can fail for various reasons, perhaps the store reduced my app’s access permissions and I’m no longer able to write notes to their orders.
In this case, I need my workflow to understand that the API call has failed and take appropriate action.
When this API request fails, I want my app to…
Turn off this feature for this user, if one API request has failed because of a permissions issue, I don’t want to keep sending failed API calls and get into issues with Shopify.
Post a message to my internal Slack, telling me which customer has had the error and the exact nature of the error (code, name and body)
Here is the workflow we are going to be working with. This is triggered whenever a new feedback message is received.
There is some conditional logic on this workflow which means it will only run when the company’s ToggleShopifyOrderNotes is YES.
This means I can control programmatically whether this feature is enabled for this customer or not (important for later)