Skip to Content
0

Http response code for Odata services

Apr 20 at 09:29 AM

61

avatar image

Hi All,


As per HTTP documentation the response code 400 should be sent when URI syntax or semantics is not as per the expectation. But we are getting this response code whenever custom code is raising message type 'E' in the process. This message is raised due to business validation failure. Just for an example if I am trying to fetch an invoice and that particular invoice is not available in the system we are getting 400 response code.

Please let me know whats the correct approach, should we suppress the message type E so that we get response code 200 or response code 400 is also applicable for Business Validation failures.

Regards,

Gaurav

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Ralf Handl
Apr 20 at 11:55 AM
0

4xx errors are client errors, and 400 is the most generic / unspecific client error, see https://tools.ietf.org/html/rfc7231#section-6.5.1:

   The 400 (Bad Request) status code indicates that the server cannot or
   will not process the request due to something that is perceived to be
   a client error

Business validation failure is a client error, the client should have sent valid business data.

200 OK would mean that the request has succeeded, which it won't if it fails business validation.

Share
10 |10000 characters needed characters left characters exceeded
gaurav dasharath sharma Apr 27 at 04:13 PM
0

Hi Ralf,

Thanks a lot for your reply. That makes absolute sense now.

But is it same when I make a expand call, for example I am trying to get the customers details with the invoice details. I am using expand here as I need to get the information in one go, but as the customer does not have any invoices due to that even the customer details are also not passed in the output. Please could you please share your thoughts.

Regards,

Gaurav

Share
10 |10000 characters needed characters left characters exceeded