Here is my request URL:
http://server.com/app/user/getuser/?userId=9999
Note that userId is query parameter. Not embedded path parameter.
I understand that if the request URL is: http://server.com/app/user/getuser/9999 and the ID 9999 does not exist in database, The code 404 should be used.
BUT what HTTP status should be used for the case userId is query parameter? Right now I am returning 400 instead of 404.
I would use 404 Not Found.
Why?
The RFC 7231 defines a 400 Bad Request response like this:
...since your request is valid and you are just trying to access a resource that does not exist, I think a 404 Not Found status is more suitable. RFC 7231 defines its meaning like this: