When making a request to the Xero API, if the response is a 400 Bad Request, then an object is returned with an Elements array that contains ValidationErrors. This is inconsistent with the rest of the API, where an Errors object is returned, making it hard (unnecessary code) to gracefully handle errors.
Expected Behavior
Responses from a 400 Bad Request should return:
Current Behavior
Currently, the API responded with the following object after a 400 Bad Request:
{
"ErrorNumber": 10,
"Type": "ValidationException",
"Message": "A validation exception occurred",
"Elements": [{
"ValidationErrors": [{
"Message": "Email address must be valid"
}]
}]
}
Context
This change in the response of errors across the API, resulted in a runtime error where it was not immediately obvious on what the cause was. This is because we were just checking for an errors object in the response.
When making a request to the Xero API, if the response is a 400 Bad Request, then an object is returned with an
Elementsarray that containsValidationErrors. This is inconsistent with the rest of the API, where anErrorsobject is returned, making it hard (unnecessary code) to gracefully handle errors.Expected Behavior
Responses from a 400 Bad Request should return:
Current Behavior
Currently, the API responded with the following object after a 400 Bad Request:
Context
This change in the response of errors across the API, resulted in a runtime error where it was not immediately obvious on what the cause was. This is because we were just checking for an
errorsobject in the response.