HTTP status codes

How are HTTP status codes handled with Backendless? Is there a way to force something other than 200?
An example would be the following: If I perform a request where no record can be found the response is empty but the status code is still 200. I would expect something like a 404.
I may misunderstand the whole concept but different status codes would be useful for me for displaying error states in a third-party tool.
Thank you in advance!

1 Like

I assume you’re talking the API routes that are built into Backendless (rather than your own API services you develop and deploy into the platform).

In most cases when the server handled a request and it resulted in an error, you’d be getting the following data structure back:

{  
  "message":error-message,  
  "code":error-code  
}

The HTTP status code is always 200, however, the error-code value would be one from the following document:
https://backendless.com/docs/rest/backendless_error_codes.html

Thanks again for the quick reply, Mark!
I was talking about the built-in API routes. However, I also tried the following API service in an attempt to get a different result:


Like you said this only returns the code in the body too.
I want to integrate Backendless with Bravo Studio but there the only way to show errors is through status codes.
I would be happy if I could continue using Backendless so if you have any other ideas please let me know :slight_smile:

It should be like this:
API Services - BL - ConsoleDemo - Backendless 2021-10-14 13-18-30

However, I just tried it and I am always getting status code 400 (the message and code do arrive as expected). I opened an internal ticket to investigate this (BKNDLSS-26525)

Regards,
Mark

Thanks for clarifying and investigating!