[ACCEPTED]-Mapping exceptions to HTTP status codes in REST web services-rest

Accepted answer
Score: 10

In general, the 4xx status codes tell the 14 client that the request failed but may succeed 13 if the request i smodified. The 5xx codes 12 inform the client about problems that where 11 the client has no influence.

So the first 10 distinction you have to make is between 9 4xx and 5xx codes, i.e. tell the client 8 if it should retry or not.

HTTP 400 "Bad 7 Request" should be used if the request was 6 indeed syntactically malformed, incomplete, contradicting 5 or otherwise basically wrong. Additionaly 4 it may be a valid default status in the 3 4xx range, if no other status seems appropriate 2 and you believe the client needs only to 1 modify the request to succeed.

Score: 1

It depends on the context. E.g. an ArgumentNullException 2 could stem from a violated precondition 1 or be an internal server error.

Regards, tamberg

More Related questions