RESTful resource not found. 404 or 204? Jersey returns 204 on null being returned from handler

The HTTP Code Definition states that the codes beginning with 2 are for successful calls and 4 for unsuccessful ones.

  • When you get the 204 it just shows you that there is nothing to return (usually you expect if you make a POST or PUT call that does not need to return anything)

  • When you get a 404 it states that the call was unsuccessful, so it will not return anything.

In your situation the 404 is appropriate, not the 204! Since you probably want to say to the caller that he made a wrong call.

Leave a Comment