Reputation: 82579
I'm making some REST services, and as I'm implementing a GET request, I was debating about what I should do if there is no record there, for example /profile/1234
. Now, if you tried to use /profiles/1234
(note the s on profiles) it would definitely be a 404 code because that URL definitely isn't found. But when it comes to there just being no 1234
profile, I'm not sure what I should return. I don't want to return {}
because that might give the impression there is a record with no data. But if I return a 404 error code, how is the consumer of the API supposed to tell the difference between the two 404s?
How can I be a responsible API designer by communicating programmatically what the difference between a service that doesn't exist and a record that doesn't exist?
Upvotes: 3
Views: 82
Reputation: 19064
You can send a custom status message which will help you differentiate between the "different" 404
s.
On the other hand, I wouldn't worry about that distinction. People are used to having to type api endpoints carefully. As long as they manually test their app a tiny bit the issue becomes a non-issue.
Upvotes: 1