Error Codes in REST Web Services

In REST web services, HTTP status codes are used to inform you about the success or failure of a request. The following status codes are used:

  • 2xx status codes are used for successful requests.
  • 4xx status codes are used for failures due to user error.
  • 5xx status codes are used for failures due to system error.

The error messages clarify whether an error occurred in the request URL, the request headers, the query parameters, or the request body. Error messages also provide more information about the cause of errors and provide possible solutions. Error responses contain the following fields.

  • status – the HTTP status code.
  • o:errorDetails – an array with error details. One error response can contain multiple error details.
    • detail – human–readable error description.
    • o:errorCode – the error category in a machine-friendly format.
    • o:errorPath (optional) – a machine-readable JSON path that points to the request body where the error occurred.
    • o:urlPath (optional) – a machine-readable URI path that points to the part of the URL where the error occurred.
    • o:errorHeader (optional) – the machine-friendly name of the request header where the error occurred.
    • o:errorQueryParam (optional) – the machine-friendly name of the request query parameter where the error occurred.

Leave a comment

Your email address will not be published. Required fields are marked *