Salesforce Flow HTTP Callout Action — handling HTTP errors — Part 2

Cloud Architect
3 min readMar 4, 2023

--

In my previous article, I determined that the new HTTP Callout Action for Flows only creates a wrapper for successful (HTTP response 200) web calls. This can be fixed by adding the error parts to the External Service (Salesforce configuration component) afterwards:

First navigate to your External Service. Note the Output Parameters that were generated when it was first created generate the ‘happy path’ of a 200 success:

You can edit this to add a new 4XX response after the existing 2XX response. Keep everything but the name the same.

Note: I recommend saving the original JSON and editing the new values in a JSON editor rather than in Salesforce.

You will now see 4XX as an output parameter:

At the end of editing, you can even see a new Apex class has been created for the new 4XX response:

Edit your Flow. Add a new Outcome to your Decision Flow Element, and ask it to catch all responses between 400 and 499 (indicating anything that is considered a problem with the client):

Add a new Screen for this Outcome, and you will now see a new 4XX reference that you can parse:

Invoking this allows you to parse the fields you defined in your Response and display to the user. You could also then choose to handle this error based on this data with a retry or logging.

You can use the same technique above to handle other the other HTTP Response categories, such as 5XX server error responses. We will look at handling scenarios for those in the next article.

--

--