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.
In my opinion, if the "user" is the resource, a better way to expose that resource is to use a URL like this: http://server.com/app/user/9999
Query parameters are best for searching a dataset, where an empty answer is still valid (200).
But, if you can't change the URL, 404 in this case is a valid option.