Skip to Content

Http response code for Odata services

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Apr 20 at 11:55 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 27 at 04:13 PM

    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

    Add comment
    10|10000 characters needed characters exceeded