Hi,

I am consuming Rest Api and I need to access value in the response text if status is  not 200. I am using OnafterResponse Rest Api callback and in that I am converting JSON data(response text) into Outsystems structure and storing it in a local Variable. Please see picture below.

I need to access value of this local variable at screen level and based on that I will display or hide containers on my screen. I am not sure how can I access this variable at screen level.

Thanks 

Hi Nannu,

You can try having this logic in a wrapper action that calls the API method and is exposed to your Screen module, rather than using the API OnAfterResponse.

That way you will be able to define your own action outputs.

Peter L wrote:

Hi Nannu,

You can try having this logic in a wrapper action that calls the API method and is exposed to your Screen module, rather than using the API OnAfterResponse.

That way you will be able to define your own action outputs.

 

 Hi Peter,

API method will throw an exception if status is not 200. So I won't be able to get the response.

Hi Nannu,

You can try with session variable.


VIjay M-

Solution

Nannu wrote:

Peter L wrote:

Hi Nannu,

You can try having this logic in a wrapper action that calls the API method and is exposed to your Screen module, rather than using the API OnAfterResponse.

That way you will be able to define your own action outputs.

 

 Hi Peter,

API method will throw an exception if status is not 200. So I won't be able to get the response.

 Hi Nannu,

You can throw your own custom exception at the end of the flow, use the deserialized Json as the exception message and catch it at your screen level.

See approach #2 here: https://www.outsystems.com/blog/posts/handling-http-status-codes-consuming-rest/

 

Solution

Vijay Malviya wrote:

Hi Nannu,

You can try with session variable.


VIjay M-

 

 Hi vijay,

I am using reactive web application.

Thanks

Peter L wrote:

Nannu wrote:

Peter L wrote:

Hi Nannu,

You can try having this logic in a wrapper action that calls the API method and is exposed to your Screen module, rather than using the API OnAfterResponse.

That way you will be able to define your own action outputs.

 

 Hi Peter,

API method will throw an exception if status is not 200. So I won't be able to get the response.

 Hi Nannu,

You can throw your own custom exception at the end of the flow, use the deserialized Json as the exception message and catch it at your screen level.

See approach #2 here: https://www.outsystems.com/blog/posts/handling-http-status-codes-consuming-rest/

 

 

 Hi Peter,

That's the approach I am following right now and it's working fine but I don't wanna display exception message. How can I hide that?

The exception message will only be displayed to users if the exception handler that catches it has a message node in the flow, you just need to replace that with your own handling logic.

Peter L wrote:

The exception message will only be displayed to users if the exception handler that catches it has a message node in the flow, you just need to replace that with your own handling logic.

 

 Hi Peter,

Please have a look at the image below. I am not displaying any error message from Api response. 

Also I am doing autosave after one minute and in that logic I didn't even add any exception but I am still seeing error coming from that logic flow as well. I checked in Service center logs. 

Thank you for your time.

Hi Nannu,

Where are you seeing this exception message that you want to hide? Is it appearing to users in the UI or are you referring to the service center logs?

Peter L wrote:

Hi Nannu,

Where are you seeing this exception message that you want to hide? Is it appearing to users in the UI or are you referring to the service center logs?

 

 It's appearing in the UI. Whatever I am putting in exception message it's displaying that.

 and this is what I am doing in OnAfterResponse.

Nannu wrote:

Peter L wrote:

The exception message will only be displayed to users if the exception handler that catches it has a message node in the flow, you just need to replace that with your own handling logic.

 

 Hi Peter,

Please have a look at the image below. I am not displaying any error message from Api response. 

Also I am doing autosave after one minute and in that logic I didn't even add any exception but I am still seeing error coming from that logic flow as well. I checked in Service center logs. 

Thank you for your time.


 And for this flow have you tried debugging it as well? Are the API action and UI screens in the same module?

 

Peter L wrote:

Nannu wrote:

Peter L wrote:

The exception message will only be displayed to users if the exception handler that catches it has a message node in the flow, you just need to replace that with your own handling logic.

 

 Hi Peter,

Please have a look at the image below. I am not displaying any error message from Api response. 

Also I am doing autosave after one minute and in that logic I didn't even add any exception but I am still seeing error coming from that logic flow as well. I checked in Service center logs. 

Thank you for your time.


 And for this flow have you tried debugging it as well? Are the API action and UI screens in the same module?

 

 

 Hi Peter,

Thank you for your help I just found out that I wasn't handling exception on my Auto save logic.