How to tell between non-existent service or no entry?
I am doing some REST services and when I am implementing a GET request I have been discussing what to do if there is no entry there, eg /profile/1234
. Now if you try to use /profiles/1234
(note the s on the profiles) it will definitely be a 404 code because that URL was definitely not found. But when it comes to the fact that there is simply no profile 1234
, I'm not sure what I should return. I don't want to return {}
because it might give the impression that there is a record with no data. But if I return a 404 error code, how is the API consumer supposed to tell the difference between the two 404s?
How can I be a responsible API constructor, programmatically programming, what's the difference between a service that doesn't exist and an entry that doesn't exist?
source to share
You can send a custom status message to help you distinguish between "different" 404
s.
On the other hand, I wouldn't bother with this difference. People are used to typing api endpoints. While they are manually testing their application, a small question becomes a problem without a problem.
source to share