Salesforce Flow HTTP Callout Action— handling HTTP errors — Part 1
The new HTTP Callout action beta available in Salesforce Flows promises a low-code solution for calling external web services. I was interested about how it would handle unreliable services and so I tried it against a service that randomly fails.
Update: I have created a newer article that shows how to get around the Error Response handling below.
Note: This is currently in Beta and could therefore change before GTM. My personal view is that Beta functionality will not change much, if at all, from a user perspective.
The main problem is that the new Action can not work with responses that fall outside of the successful response range (200–299). The action can pickup the code and deal with it individually, however with too many potential codes that could lead to a very complex Flow! Additionally, there is no ability for the service to provide any further data in the response — for example you passed a bad request, but which property was failing?
The Flow I built below handles just 200 (success) and 400 (Bad Request):
Experience
‘Happy Path’ Test:
This is what happens when the service works fine. The service can pass back all kinds of data in the response and it can all be used:
Handled Error Test:
The flow is looking for a ‘400’ HTTP response code (Bad Request), so at least we can give the user feedback on that. All the other details the service has written to the response are not available to the Flow, even if the debug can surface it:
Unhandled Error Test:
Worst case is that the flow is not looking for the 429 HTTP response code at all, so the best we can do is just display the code to the user:
Summary
If your web service is not critical and you don’t care about error handling then it is worth looking at using this action.
However I suspect that for most scenarios it isn’t feasible to build an elaborate error handling and retry framework in Salesforce Flows, and therefore you would usually be better off with either:
- Salesforce Apex web service callout — code based web service handling
- MuleSoft Flow — configuration based web service handling and retry
+++++++++++++++++++++++++++++++++++++++++
Setting it up (if you are interested):
Create your unreliable service. I used Microsoft Azure Function, and just randomly retuned different HTTP status codes:
By design sometimes a call will work, and sometimes it will fail.
Setup your HTTP Callout with an appropriate named credential:
Pass in the JSON response: