I'm working on an restful API back end, and we only use json as content type. And There are two ways of performing error response as I know:
- HTTP status code is always 200, and the returning json should contain error code and error message.
- Treat HTTP status code as part of our API, we may pick HTTP error code(4XX) to corresponding error condition. And we can include a json document in the payload to includes a sub-code and a descriptive comment.
I want to know which one is more idiom for a restful service?