Hacker News new | ask | show | jobs
by vinceve 3568 days ago
What about error representation? Most of the time I find that actually representing errors is the hard part of creating a REST api.

You usually want some representation of each field, plus maybe a generic one. I always have troubles with this. Is there a standard or a proper way to define/do this? I would be very interested.

2 comments

There's an RFC for that! https://tools.ietf.org/html/rfc7807
If you are returning multiple errors of different types, (403 for the forbidden change and 422 for the incorrectly set field) then you are supposed to role it up into a generic 400. Google JSON API for more information about the right way to represent multiple errors at a time.