I am developing a RESTful API. One of the URLs allows the caller to request the record for a specific person by id.
What is the conventional value to return of the record for that id does not exist? Should the server send back an empty object or maybe a 404, or something else?
Thanks.
404, or perhaps 410 (Gone) if it was there before (but 404 isn’t wrong in this case either).
As always with REST, it’s also preferable to send a representation with it (even with a 4xx code) to tell the client that the resource does not exist and tell it what possible actions it can take from there.