How to handle REST API response timeout exception and show custom error message
Application Type
Reactive

I am getting error after REST API response timeout innerHTML undefined  i have to overwrite this message into meaningful message.

mvp_badge
MVP
Solution

Hi Apoorv,

The documentation that César Shared, explains how to Customize the response of an API that you are exposing.

In case you are consuming an external API and this API is returning an error that you want to handle, you can check this documentation.


Basically you can do it in 2 ways.


The first one, is wrapping your REST Call in an action, and in this action you can create an error handler flow:

This way you can have a specific message if the default error message or the error code is the one you want to handle. Doing it this way will also ensure this exception will be handled only for this call using this action.

________

If you want a broader solution that will be used by all methods in an API endpoint, or even if you want to get and parse your response even before OutSystems throw an exception, you can go with the second way, which is creating a OnAfterResponse action event to your REST endpoint where you can change the response content and even the response code:

To do that, select your Main Rest API node on the Service Studio, and on its properties you will see an OnAfterResponse event that you can create:



Hope it helps,

Cheers and Regards,
RR :)

Hi
Raphael Ranieri Thankyou For Your Solution It Works for Response API Status I Can Overwrite My Message Into Meaningful After Exception Handling.

mvp_badge
MVP
Solution

Hi Apoorv,

The documentation that César Shared, explains how to Customize the response of an API that you are exposing.

In case you are consuming an external API and this API is returning an error that you want to handle, you can check this documentation.


Basically you can do it in 2 ways.


The first one, is wrapping your REST Call in an action, and in this action you can create an error handler flow:

This way you can have a specific message if the default error message or the error code is the one you want to handle. Doing it this way will also ensure this exception will be handled only for this call using this action.

________

If you want a broader solution that will be used by all methods in an API endpoint, or even if you want to get and parse your response even before OutSystems throw an exception, you can go with the second way, which is creating a OnAfterResponse action event to your REST endpoint where you can change the response content and even the response code:

To do that, select your Main Rest API node on the Service Studio, and on its properties you will see an OnAfterResponse event that you can create:



Hope it helps,

Cheers and Regards,
RR :)

Hi
Raphael Ranieri Thankyou For Your Solution It Works for Response API Status I Can Overwrite My Message Into Meaningful After Exception Handling.

Hi Apoorv,

Here is the useful link where you will find solution easily please take reference and resolve your issue.

https://www.outsystems.com/forums/discussion/56296/rest-api-timeout-issue/

Make a nice day!!

Kind Regards,

Ajit Kurane.

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