3 ms·
I like the idea but I wonder how it plays together with "human-friendly" APIs that return error codes and HTML. Should you use Accept: headers to signify that y
by xg15 12y ago
I like the idea but I wonder how it plays together with "human-friendly" APIs that return error codes and HTML. Should you use Accept: headers to signify that you want a machine-readable error message?
- awinder 12y agoYou could definitely use content negotiation to present human-friendly errors if you were exposing HTML out of the API itself. But otherwise the concept of "human friendly" APIs seems a little weird to me. Likewise, the idea that error codes are more friendly than links to error entities also seems way more developer- / human-friendly. Random per-application error codes seem like a really bad idea to me, if you have the need to expose more information about a group of errors, the right way seems like this approach - link to a common error object, which itself contains classification details
- xg15 12y agoYou are right that this is no good idea in the general case. But I think there are a few endpoints that have "pretty printing" outputs for developers enabled if text/html is in the accept list. At least the (internal) deviantart API did have that some time ago. I agree that the whole thing can be solved nicely with content negotiation.