Fail Response-type
A Fail response is returned whenever the API could not process a request due to incorrect input. Examples are usage of invalid parameters, incorrect authentication or simply a resource that could not be found. On the transport level, Fail responses are combined with a HTTP status code from the Client Error range (400-499).
Required keys
- status: Will always be set to “fail”.
- data: Wrapper for any data returned by the API call. If the call returns no data, it will be set to null.
An example Fail response is:
{
"status": "fail",
"data": {
"vatCountryCode": [
"Invalid VAT Country-code specified"
]
}
}
In the example above, the key vatCountryCode
indicates an issue with a specific input-field. When multiple validation errors are reported, more than one key may be present in one response.
The fail-reason may be spanning multiple input fields, or even may be related to the whole request. In those cases, no key(s) to the error messages can be provided. The error message will be the only part of the data object, like in the example below:
{
"status": "fail",
"data": "Authorization has been denied for this request."
}