Interpretation 400 response
  • 18 Sep 2024
  • 2 Minutes to read
  • Dark
    Light

Interpretation 400 response

  • Dark
    Light

Article summary

If a functional error occurs in the content of the request, a 400 response message will be returned. There are many possible reasons for a 400 response, ranging from a missing compulsory data field to a reference number which does not match with an entity in the Bloxs database. A correct interpretation of the 400 response is essential since it provides the user with the necessary information to correct the request in order to resend it.

All 400 responses have the following structure:

{
  "type": "string",
  "title": "string",
  "traceId": "string",
  "status": 0,
  "errors": {
    "additionalProp1": [
      "string"
    ],
    "additionalProp2": [
      "string"
    ],
    "additionalProp3": [
      "string"
    ]
  }
}
  • type: Contains an url leading to a more detailed description of the REST error codes. This is a general explanation and is not specific for the Bloxs API’s. The url does not depend on the error and always contains the same value.

  • title: Contains a brief description of the response code. For the 400 response this always includes the text:One or more validation errors occurred.’

  • traceId: Contains a GUID that is unique per response. In case of troubleshooting the traceId can be used to identify the error response.

  • status: Contains the error code. Therefore, for the 400 response the value will always be ‘400’.

  • errors: Contains information about the actual error in the request message.

    • additionalProp1: Contains the property from the request in which an error has occurred. This is combined with further details about what is wrong with the content of this property in the request. In the actual error message ‘additionalProp1’ is replaced with the actual name of the property. Since a request can contain multiple errors, it is possible that multiple properties are shown under ‘errors’.

Examples

To provide a further illustration of the 400 response message, several examples are shown below:

{
    "errors": {
        "Address": [
            "The Address field is required."
        ],
        "CategoryName": [
            "The CategoryName field is required."
        ]
    },
    "type": "https://tools.ietf.org/html/rfc9110#section-15.5.1",
    "title": "One or more validation errors occurred.",
    "status": 400,
    "traceId": "00-bb06dc789f348c93740607862877c712-32164bf4f1a706a8-00"
}

{
    "errors": {
        "CategoryName": [
            "There is no category named 'Woning' known in the system."
        ]
    },
    "type": "https://tools.ietf.org/html/rfc9110#section-15.5.1",
    "title": "One or more validation errors occurred.",
    "status": 400,
    "traceId": "00-ebb17f4c8f8c4d34c3e9a5ccbf2c9cfa-8449f1d30e991e47-00"
}

{
    "errors": {
        "Address": [
            "Invalid character after parsing property name. Expected ':' but got: ;. Path 'Address', line 15, position 18."
        ]
    },
    "type": "https://tools.ietf.org/html/rfc9110#section-15.5.1",
    "title": "One or more validation errors occurred.",
    "status": 400,
    "traceId": "00-7b103c1afdc140da4af5ba89bc221e27-1ab9c10808efdc1f-00"
}


What's Next