Hot answers tagged


GET /api/sprinkler that returns 200 and {"status": "on"/"off"/"damaged"/"no water".....} In my view assigning meaning to error codes which already have a defined meaning is a bad idea. How would you distinguish between "off" sprinklers and "client pointing at the wrong url" exceptions?


For your case, I believe returning { "status" : "off" } With a 200 status code is "correct". In practice, it doesn't matter much. When Fielding published his famous rant on hypertext, he called out a particular error in this way: Failure here implies that out-of-band information is driving interaction instead of hypertext. Out-of-band in this ...


From my understanding, the solution 1 misunderstood the semantics of the HTTP status code. From RFC HTTP/1.1: Status code Definitions 10.4 Client Error 4xx The 4xx class of status code is intended for cases in which the client seems to have erred. In you example, it's a matter of resource representation. Because you are probably thinking that a ...


The proper HTTP error code on input is 400: Bad Request. In the response you could go with 500. If there is an error in marshalling or unmarshalling, an exception will be thrown which you can handle by registering an ExceptionMapper (scoll down to the Exception Mapping section). You can then determine what kind of error to throw. The JAX-RS package has a ...

Only top voted, non community-wiki answers of a minimum length are eligible