Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

Handling 404 Error on API Query

Hi,

I have an Table Iterator that runs over a table with a column like "item_id".

Each iteration calls an API Query component, which uses the "item_id" as a parameter in the URL of the API call, like this:
<rsb:set attr="uri" value="https://example.com/api/v1.0/itemdetails/[_input.item_id]/" />

I've discovered that for some tiny fraction of item_ids, the URL returns a 404 error. Perhaps this is bad design on the part of the publisher of this API! Nonetheless...

I want to handle the 404 error differently from other errors. For example, if the API Query component fails for any OTHER reason...like an authentication issue, or the web service just is temporarily unavailable...then I want to use a Retry component to keep trying, over time. But if it gets a 404 error, then I want to just stop immediately, and move to the next iteration (the next "item_id").

I cannot figure out how to accomplish this. Any suggestions?

3 Community Answers

Matillion Agent  

Kalyan Arangam —

Hi Kevin,

You may move your API Query component to a child job to build more detail on what needs to happen on failure.

Here’s what the child job may look like -

Start->APIQuery->(OnFail) IF (${variable}="404 message")->(TRUE) EndSuccess-> (FALSE) EndFailure

Create a local variable and Export the error message on APIQuery to this variable. Add a IF component to OnERROR path from API Query. Check if the variable has a 404 error in it and if TRUE, add a EndSUCCESS node. Else, add End Failure so parent job is notified.

In the parent job, you may replace the API Query component with child job and add a Retry component to the child-job.

Hope that helps.

Best
Kalyan


Kevin Havice —

"Export the error message" is the part I wasn't sure about. I am guessing maybe you are saying I should go to the "Export" tab of the API Query component, and export the "Message" -- would that be it?

Thanks, Kalyan!


Matillion Agent  

Kalyan Arangam —

Hi Kevin,

Thats what I meant. Apologies for taking the shortcut!

Best
Kalyan

Post Your Community Answer

To add an answer please login