Is it possible to Change status code in response headers?
Application Type
Mobile, Reactive, Service

Whenever we call any api from outsystems, We see 200Ok as status in response headers irrespective of the response of api. But when we see the response in it, we see the actual response, even if api gives 400 bad request , we can see that in response as 400 bad request but not in response headers of network tab. Can this be changed?

Work done around: Handled an exception onAfterResponse for API and checked if it has an error, and tried to set the status code there, But still whatever we do here we can see in response, but still the status code in response headers of network tab remains 200Ok.

Can anyone suggest is this the normal behaviour of Outsystems, or anything I have to do additionally to handle it. 

Thank you.


You could easily achieve that by using SetStatusCode action from HTTPRequestHandler extension. You should just add it at the end of your API action and it will set the status accordingly.



HI Bodgan Boglea,

yeah we tried to use this action and set status code in OnafterResponse action . But still It rmains 200OK in network tab response headers

Did you try putting it in your actual API action? (not in the OnAfterResponse)

I have an example from Postman (this is an API exposed from OutSystems) where I use this exact logic and I can customize the response status to 202 in this case:

When we consume the Api in outsystems We dont get ApI action right?, Its just we get a pop up dialog box and we get to test our API there .

Screenshot 2022-03-29 at 2.40.53 PM.png

We may get that option for api exposed api from outsystems, what to do if are consuming some external api's in outsystems, there we are not getting that option

Indeed, but in that case wouldn't you want to use the status codes that the consumed API throws by default?

In case it always throws 200 even if the request is incorrect you could use OnAfterResponse, not OnBeforeRequest, since this allows you to manipulate the response and create custom logic.

See if that helps.

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