171
Views
3
Comments
how to add status code in any api
Question
Application Type
Reactive

Hi All,

I have a get and post Api but those api dont have any status code but i want status as response . how can i add add status code in any api response.

Please suggest me any idea .and please send me any link or oml file??

2021-10-09 07-57-44
Stefan Weber
 
MVP

Hi

To set a status code use the SetStatusCode action from the HttpRequestHandler module.

For all 2XX codes use this action in your regular flow. Add a user exception after all error codes.

Best

Stefan

UserImage.jpg
vikas sharma
Champion

Hi,

You need to set status code by calling the SetStatusCode  method. For more details about HTTP status code and how to set its value please go through this URL : https://success.outsystems.com/Documentation/11/Reference/OutSystems_Language/Extensibility_and_Integration/REST_APIs/Exposed_REST_API/Built-in_HTTP_Status_Codes

You can use the SetStatusCode action of the HTTPRequestHandler extension to set a custom status code. Please note that this is an advanced extensibility scenario, so be sure to test if it works as intended in your specific infrastructure. 

regards

2023-10-21 19-42-11
Tousif Khan
Champion

Hello

Here we have a step by step guide to implement HTTP Status Codes, while Exposing a Rest API 
Check here - https://www.outsystems.com/blog/posts/implementing-http-status-code-exposing-rest/

Thanks

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