Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP 400 Bad Request should use a standard error object #461

Open
mark-strudwick opened this issue Oct 4, 2021 · 0 comments
Open

HTTP 400 Bad Request should use a standard error object #461

mark-strudwick opened this issue Oct 4, 2021 · 0 comments

Comments

@mark-strudwick
Copy link

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:

{
   "errors": {
        ....
    }
}

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.

@mark-strudwick mark-strudwick changed the title HTTP 400 Bad Request should follow standard error object flow HTTP 400 Bad Request should use a standard error object Oct 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant