Errors

HTTP errors

There are five possible types of client errors on API calls that receive request bodies:

  1. Sending invalid JSON will result:
HTTP/1.1 400 Bad Request
  1. Sending the wrong type of JSON values will result:
HTTP/1.1 400 Bad Request
  1. An error occured in the application server will result:
HTTP/1.1 500 Internal Error
  1. Accessing resources without the permissions will result:
HTTP/1.1 401 UNAUTHORIZED
  1. Generating too many API calls will result:
HTTP/1.1 429 Too Many Requests

Validation errors

There are two types of error:

Type (classification) Description
RequiredError A required attribute is missing.
ValueError An attribute value is invalid (wrong format, unsupported, etc).

Errors always go with:

  • fieldNames: array of required/invalid fields
  • message: error description

Required field

When you submit a form and forget a required field, the response will return a 422 status code with the following JSON:

[
    {
        "message": "Required",
        "classification": "RequiredError",
        "fieldNames": [
            "field_name"
        ]
    }
]

Invalid value

When you submit a form with an invalid value, the response will return a 422 status code with the following JSON:

[
    {
        "message": "Error description",
        "classification": "ValueError",
        "fieldNames": [
            "field_name"
        ]
    }
]

Example

HTTP/1.1 422 UNPROCESSABLE ENTITY
Vary: Accept
Content-Type: text/javascript

 [
     {
         "classification": "RequiredError",
         "fieldNames": [
             "amount"
         ],
         "message": "Required"
     },
     {
         "classification": "RequiredError",
         "fieldNames": [
             "country"
         ],
         "message": "Country is required"
     },
     {
         "classification": "ValueError",
         "fieldNames": [
             "nationality"
         ],
         "message": "Nationality is invalid"
     },
     {
         "classification": "ValueError",
         "fieldNames": [
             "lang"
         ],
         "message": "Language is invalid"
     }
 ]