REST API Return Status CODE

Hey There,

I would like to ask about the return status code.
My question, when I testing the API using the postman, when there is any error in the code (bad request) the post return the status with 200.
Can someone assist me to show in CUBA how to return the correct status code.

Below is the image for your reference

Hi,

REST API service endpoints cannot return status codes themselves. If you need this functionality you should create regular Spring MVC controllers.

However, if you need to return responses with different codes for exceptions thrown from middleware services, then you can try writing your custom exception handler. See this discussion.

1 Like

Thank you for great explanation