i'm constructing a web-service that is used, in this particular case, to ask for information about a patron.
Let's say, for the sake of argument, that the lookup web hit is:
GET /patrons/619 HTTP/1.1
If the patron is found, i return code 200:
HTTP/1.1 200 OK
If you omit, or give an account number that is not a number, i return 400. For example the following bad requests:
GET /patrons HTTP/1.1
GET /patrons/ HTTP/1.1
GET /patrons/G619 HTTP/1.1
GET /patrons/kirsten%20guyer HTTP/1.1
all return error 400 (Bad Request), e.g.:
HTTP/1.1 400 Invalid patron number
i want to have a status code for patron not found, returned as the HTTP status code. For example:
GET /patrons/1322 HTTP/1.1
HTTP/1.1 404 Not Found
i've thought about using 404 (Not Found), which is a valid response (the requested resource was, really and truely, not found.) But i'm afraid people debugging it might think that it means that they spelled /patrons/
wrong.
Can anyone think of another http status code i could use?
Update: i'm eyeballing
204 No Content
The server successfully processed the request, but is not returning any content.
What say you?
Don't forget, that not all HTTP servers serve up HTML content. If an IIS web-server is asked for a resource called:
GET /MyStartPage.html HTTP/1.1
Then the HTTP server has to decide what to respond with. On most web-servers, a resource named /MyStartPage.html corresponds to a file sitting on the hard drive.
Whereas StackOverflow does:
GET /posts/1027301 HTTP/1.1
Which, if that resource doesn't exist, the web-server should (rightly) return 404.