how can I get the response from an Api Rest with error 400,500,404 etc in my stream?
Question

normally I can get the response from my REST API as long as the response code of the request is 200. I have scenarios where depending on the error code I can get a different response for example:


error 400:

`

{

   "error":{

      "validations":[

         {

            "problem": "email is not unique"

         }

      ]

   }

}

`

error 500

`

{

 "message": "data is incorrect"

}

`

in this current flow:




if I get an error code in the request other than 200, I can't catch the error. How can I get the response from the Api Rest request to show the user the message based on the possible data outputs.

my idea is something like this:



I am very new to this, so please I would ask you the big favor to explain me as understandable as possible for example from where I can get a certain element or something like that. Thank you very much




Hi Yeison.

You may implement your logic on the callback OnAfterResponse depending on the status code.

Take a look at this article https://www.outsystems.com/blog/posts/handling-http-status-codes-consuming-rest/

more or less at the final.

Also from Rui Barbosa, you have a how to forge component for you to take a look: https://www.outsystems.com/forge/component-overview/5547/rest-http-codes

Hope it can help you :-).



Hi,

I hope your doing well!

Please refer below link ,

https://www.outsystems.com/forums/discussion/42492/consume-rest-api-400-bad-request/


Kind Regards,


Rasika modi.

Yes its helpful.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.