3 ms·
Precisely, I think people try to put too much semantic meaning into HTTP status codes. If you read the spec, most of the exotic semantics are actually part of
by grandalf 13y ago
Precisely, I think people try to put too much semantic meaning into HTTP status codes. If you read the spec, most of the exotic semantics are actually part of the WebDAV spec and not actually the HTTP spec.
For something like a pure REST API, basic status codes are fine. It's when you start breaking the REST abstraction (which a human-readable landing page surely does) that it gets tempting to start misusing status codes.
For any kind of non-RESTful or procedural API, HTTP status codes are simply not adequate and application-specific error handling is necessary (HTTP response 200, app-specific-error 999, etc.).
- jrochkind1 13y agoIf you don't think any meaning should be taken from http status codes, then why set/send them at all, why do they exist? If any meaning is going to be taken from them at all, then the difference between "OK" and "Server Error" seems pretty basic and fundamental.
- grandalf 13y agoWell, to illustrate my point just look at the WebDAV spec vs the HTTP spec. WebDAV shows how you can add more semantics to HTTP response codes. But when you think about it, for a pure REST API you really only need classic HTTP response codes. Response codes only make sense in the context of a resource. Once you introduce query strings or start to stretch the meaning of HTTP verbs the abstraction starts to leak. So when designing an API it's smart to just handle errors at the application level rather than at the protocol level. Protcol level errors are for things that are outside of the application. An error response with data validation errors should return a 200, for example.