Search code examples
apiarchitectureresponseapi-design

API response, with multiple error information


I was building my API when this question came out:

I am making an API to set or get stuff, for the example i try to set but i have two field with error, what's the best way to answer the errors ?

  • Answer only one error ?
  • Answer all the errors ?

In my opinion, answer all the errors is the best solution but not for my boss .

What's the best for this kind of work ?


Solution

    • Definitely all validation errors should be pass back to client.
    • Moreover, you should specify code of errors, while error message can vary for different situation. Standard error codes can help you to create tests for your api.
    • Also you should add versioning for your api from the beginning, because when you open your api for clients it should be stable. And incompatible changes can be done only in next version of your api