cancel
Showing results for 
Search instead for 
Did you mean: 

web api response when getting error

MalinKarlsson
Level 2
Hi, 
First time for me here 🙂
I configured a web api POST . The request body template is set to template and I also set up a parameter (CardNumber)the templatecode is:

{
"blockType": "TEMPORARY",
"cardNumber": "[cardNumber]",
"delay": 0,
"reason": "LOST"
}

I have not configured anything for the response.
Everything works perfectly when I get HTTP Status Code 200 back. The data item HTTP Status Code is set to 200 , the resonse header ends up with a lot of data, Response content data item is empty but everything goes on fine.
But I would like to handle errors. When something goes wrong ex 400 , I get a pop Up see attachment and the process does not walk on.  The text in the pop up is:
Internal : Unexpected error Error during Web API HTTP Request
HTTP Status Code: 422
HTTP Response Content: {"error":"CARD_IS_NOT_ACTIVE","message":"Card is not an active card","details":null}

I would like the response content text : {"error":"CARD_IS_NOT_ACTIVE","message":"Card is not an active card","details":null} to end up in the parameter/data item response content and the HTTP Status Code: 422 in the data time . The same way as for response 200. Look at my attached pic. Please help me. //Malin




------------------------------
Malin Karlsson
developer
Volvofinans Bank
Europe/Stockholm
------------------------------
2 REPLIES 2

Hi Malin,

Welcome to the BluePrism Community.

The WebAPI feature currently does not contain functionality to deal with non 200/201 status codes without throwing up pop up. You could handle this in your process call by using recover stages as below:

26353.png

As an alternative you can use the HTTP - Utility VBO also available on DX to make HTTP calls. The VBO can give you any response 200/400 etc. in Data Items directly without throwing up popups as the exception handling is done within the HTTP Utility itself.

------------------------------
Shashank Kumar
DX Integrations Partner Consultant
Blue Prism
Singapore
+6581326707
------------------------------

Hi Malin,

Thank you for sharing and for the detail in your post.

As Shashank rightly mentioned the process will generate an exception when a 400 response returns, in your case a customer 422 response.

When this exception occurs what you can do to log it and prevent the process from freezing or just terminating is to recover, write down the exception detail and reason and then resume in that order using a multi-calc stage.
26354.png
Below is what we use in our internal processes in BluePrism, we keep the Exception Type and Exception Detail as data items for each case and during the exception path if there are certain types of exception such as your 422 we can search the data item using an 'InStr' function to look for "422" and if True we can either choose to retry, not retry, or send custom emails/notifications in either instance.

Let me know if you have more questions, hope this helps!

Best Regards,



------------------------------
Ronan Considine
Senior Business Analyst
Blue Prism
------------------------------
Ronan Considine Senior Business Analyst Blue Prism