Error handling API calls within iterations

I have a scenario where I’m running a workflow iterating over an array. For each item in the array, I make an API call to enrich data (i.e. I have an API call block after the iteration starts).

The issue I’m having is that the whole workflow stops if the API returns an error for one particular item (e.g. a 404 or 500 error).

Is there any way I can handle the error and let the iteration continue for other values?

1 Like

I havent tried this… but, I’m not sure of any other way to do it except with your own javascript instead of the Rest API workflow action.

I’m guessing that each action is wrapped in a try/catch block.

So, you would need to write your own try/catch inside of the custom javascript action that defines the result of the API call. Then, it wouldn’t throw an error for the action.

You can use axios inside the javacsript.

1 Like

Yeah that should work - I was hoping to avoid the javascript block… It also means not being able to use the server side API call. I’ll try it

Thanks for your help

1 Like

One other comment on this: I tried putting just the API call in its own global workflow, with error handling and then calling that workflow after the iteration block.

I thought that would be a nice workaround but it basically doesn’t make a difference, and the API call error handling never gets calls. Is this desired behaviour?