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

Posted by jr on Stack Overflow See other posts from Stack Overflow or by jr
Published on 2010-02-03T21:35:19Z Indexed on 2010/04/02 16:53 UTC
Read the original article Hit count: 237

Filed under:
|
|

If you are looking for /Resource/Id and that resource does not exist, I had always though that 404 was the appropriate response. However, when returning "null" from a Jersey handler, I get back a "204 No Content". I can likely work with either one, but am curious to others thoughts on this.

To answer my own next question. To get jersey to return 404 you must throw an exception.

    if (a == null)
        throw new WebApplicationException(404);

© Stack Overflow or respective owner

Related posts about jersey

Related posts about rest