For example you run a GET request for
See This Blog. It explains it very well.
Summary of the blog's comments on
204 No Contentis not terribly useful as a response code for a browser (although according to the HTTP spec browsers do need to understand it as a 'don't change the view' response code).
204 No Contentis however, very useful for ajax web services which may want to indicate success without having to return something. (Especially in cases like
POSTs that don't require feedback).
The answer, therefore, to your question is use
404 in your case.
204 is a specialized reponse code that you shouldn't often return to a browser in response to a
The other response codes are even less appropriate than
200should be returned with the body of whatever you successfully fetched. Not appropriate when the entity you're fetching doesn't exist.
202is used when the server has begun work on an object but the object isn't fully ready yet. Certainly not the case here. You haven't begun, nor will you begin, construction of user 9 in response to a
GETrequest. That breaks all sorts of rules.
400is used in response to a poorly formatted HTTP request (for instance malformed http headers, incorrectly ordered segments, etc). This will almost certainly be handled by whatever framework you're using. You shouldn't have to deal with this unless you're writing your own server from scratch. Edit: Newer RFCs now allow for 400 to be used for semantically invalid requests.