How to customize REST API Error Message ?
Application Type
Traditional Web, Mobile, Reactive, Service

Hi All,

Is it possible to customize the Error message of REST API in Service center? 

In service center for 400 status code I am getting "400 Bad Request" that I want to customize.

For Ex.

If "Message" is "400 Bad Request" then I want to show "It's a Bad Request. Please Try again

I want to customize for all 4K and 5K error code.

I am referring below link but updated status message  is not reflecting in Service Center.

How to Handle HTTP Status Codes When Consuming a REST API in OutSystems 

I tried "CustomizedResponse.StatusLine" = "Message" & CustomizedResponse.ResponseText = "Message" but both are not working.

Thanks

Hi Khris,

1] Under "Common" UI Flows open "OnException" 

2] Take "ExceptionHandler" widget and select "AllExceptions"

3] In Logic TAB Expand "Systems" Drag "LogMessage" and Customize your message on "Message" property.

So, whatever exception you get it you can able to see it Service Center's  "General Log"

I hope it will help you

Regards


Hey Thanks Shailendra

It worked for me :-)

Hi,

You can try to raise an exception in the REST API.

The REST API will return this:

The exception message will be the error message in Service Center.

Kind regards, David.

Hi David,

Thanks for reply.

REST API is retuning "400 Bad Request" that I can't customized. I am a OS developer. I can't request this to API developer to update this error message in api.

API is retuning "400 Bad Request " message that I want to customize. 

Champion

Hello Khris

Best Practice to Handle Rest Status or Modify Messages is by Generating the Rest Exception. Otherwise you can use this Component too. 

Hi Khris,

1] Under "Common" UI Flows open "OnException" 

2] Take "ExceptionHandler" widget and select "AllExceptions"

3] In Logic TAB Expand "Systems" Drag "LogMessage" and Customize your message on "Message" property.

So, whatever exception you get it you can able to see it Service Center's  "General Log"

I hope it will help you

Regards


Hey Thanks Shailendra

It worked for me :-)

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