cancel
Showing results for 
Search instead for 
Did you mean: 

Http response code for Odata services

0 Kudos

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

Accepted Solutions (0)

Answers (2)

Answers (2)

0 Kudos

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

RalfHandl
Product and Topic Expert
Product and Topic Expert
0 Kudos

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.