I am working on making a rest api and I have a question about what is typically returned from a get with no match. For instance if my resource is "users" and I make an api call with
http method: GET url: api.mysite.com/users/123
If '123' exists I will return a http code of 200 with the details of the user in the response body. My question is; what http code should I return, and what should I put in the response body if there is no user with the id of 123?
Should I just return a code of 200 and an empty body?
Use 404, because requested resource (User) not exist.
10.4.5 404 Not Found
The server has not found anything matching the Request-URI. No indication is given of whether the condition is temporary or permanent. The 410 (Gone) status code SHOULD be used if the server knows, through some internally configurable mechanism, that an old resource is permanently unavailable and has no forwarding address. This status code is commonly used when the server does not wish to reveal exactly why the request has been refused, or when no other response is applicable. RFC 2616