|
It depends. If the request is coming to /api/resource/{id}, then it's a 404. The spec states:
Quote: 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.
If it's as the result of parameters (/api/resource/?foo=bar), then I'd give a 200 and an empty result.
|
|
|
|
|
I had been using 404 when I also had the same trouble that you did and also read the same article that you did.
So now I return 200 and an empty data object.
It is easy to check the object for being empty, if I want to display an appropriate message or take some particular action.
There are no undesirable error messages popping up.
I explained this to my supervisor and he agreed.
-- modified 22-Feb-18 9:51am.
|
|
|
|
|
Just an non-technical opinion: Be pragmatic, => https://en.wikipedia.org/wiki/Pragmatism
…and do as your employer says.
Think in your anal annual review, it will say “...grasps concepts quickly” instead of “… needs improvement on taking orders” .
Experience has teach me that I don’t have to lose my mind in minor details because every single employer sometimes will have a crazy idea and somehow they think that my “loyalty” is in doubt if I don’t do the same way they planned.
BUT, you have to be aware of “suicide ideas”. i.e. ideas from your employer that will jeopardize either profits or real world operations. Then you have to show your point of view with clear numbers although finally they implement that suicide idea. In that case of frustration I recommend a couple of Samuel Adams or Molson Canadian.
Crazy ideas (manageable ones) => Ok, do it. (Even when they sound a little crazy)
Suicide ideas => Show clearly your point of view. (but don’t lose your mind if you are requested to implement)
Only my humble point of view.
|
|
|
|
|
Sometimes I feel like no one reads the specs. The HTTP spec is one of the shorter ones too.
Forget about Exceptions, that's just your framework letting you down. An HTTP status code is not an exception or a technical error it's a status code. Using exceptions for that is like throwing an integer instead of an exception. The exception to this is when it's a technical error - those errors are in the 500s.
URL means uniform resource locator. That means it's the string(usually) that can be used to locate some resource. You your URL of mydomain.com/product/x is the locator for product x then the status code should reflect that. If the product has never existed then you should return 404, if you've moved it you should return 301, and if you've permanently deleted it then return 410.
|
|
|
|
|
Reading the definition of a 404:
The requested resource could not be found but may be available in the future. Subsequent requests by the client are permissible.
It literally says the RESOURCE, which I assume is what you are looking for, cannot be found.
I see how it could be confused with a MALFORMED request: "site/admn/XXX" instead of "site/admin/XXX"
But that should be RARE when implementing an API. And it has to be debugged.
I do not see an appropriate code to return otherwise.
Now, when we deal with a call to returns no data. We literally return 0 rows of data (I just checked).
And yes, the code is cleaner. A 404 starts to imply there is a SERVICE issue.
Hmmm, now it boils down to whether this is an EXCEPTION or not. In our API, ZERO results is NOT an exception.
|
|
|
|
|
Sander Rossel wrote: I get that we did not find product x, but there must be a better way to separate functional from technical error...
How do you handle this?
Technical errors are 500.
User isn't going to fix it and it isn't likely it is going to fix itself.
But other than that doesn't matter to me whether an empty result is returned or 404 is. Should be consistent though and certainly should be what the caller (software) expects.
|
|
|
|
|
|
I'm with you on this. 404 is an HTTP code. It's a transport condition, not a data condition.
The correct code to return is 204.
204 No Content
The server successfully processed the request and is not returning any content.
List of HTTP status codes - Wikipedia
|
|
|
|
|
Just reading this about bowing and curtsying...
What happens if you don't bow/curtsy? Is there jail time, a fine, hand spanked??
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Traditionally you are going to be deported to Australia.
I have lived with several Zen masters - all of them were cats.
|
|
|
|
|
Australian Border Security: - Purpose of visit?
Me - Business
Australian Border Security: - Do you have a criminal record?
Me - Is that still required?
I'm pretty sure I would not like to live in a world in which I would never be offended.
I am absolutely certain I don't want to live in a world in which you would never be offended.
Freedom doesn't mean the absence of things you don't like.
Dave
|
|
|
|
|
|
|
I wonder if that really is the block and axe that did her in, or that is just some period piece and they say it is the real thing, but it really isn't.
Also, I noticed that the striking surface is quite narrow. Leaving much room for error I suppose...a few chops instead of one. More entertainment for the masses?
I have so many questions about this.
-- rants are the vehicle of the lazy and uninspired - JSOP 2/2018
|
|
|
|
|
Anne Boleyn was beheaded with a sword, not an axe, so no, its not the real thing.
|
|
|
|
|
AFAIK Catherine Howard and Jane Boleyn were beheaded with an axe.
|
|
|
|
|
Jane Boleyn was the sister of Anne, and was indeed executed with an Axe. Anne Boleyn, Henry VIII's 2nd wife was executed by sword. There's a discussion of why that might have been here: Anne Boleyn’s last secret | The Spectator
|
|
|
|
|
On the other hand - that nice scoop out for the head is very considerate - much more comfy compared to having to bend your neck every which way until you're comfortable.
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
No punishment is too terrible for such treasonous behaviour.
|
|
|
|
|
Quote: Commoners don't have to bow or curtsy to members of the royal family ... Thanks for the post, I had not given the subject any thought, but I now know that a bow is not expected of me.
(Not that they would ever have got one.)
|
|
|
|
|
Kevin Marois wrote: What happens if you don't bow/curtsy? Is there jail time, a fine, hand spanked??
Nothing happens - there is no law, only tradition. You are free to bow or not - the United Kingdom is a Democracy, not a Kingdom. Wait...
Keep your friends close. Keep Kill your enemies closer.
The End
|
|
|
|
|
I guess that I figured with the plethora of stupid laws we have in the U.S., that may be the same held true for the U.K.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Kevin Marois wrote: that may be the same held true for the U.K.
Oh it does. Just not in this case.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
We Dutch will never bow for the Brits
|
|
|
|
|
Good attitude, like it. Never bow to anyone!
|
|
|
|