|
|
|
|
|
by inanutshellus
1433 days ago
|
|
Your argument is obviously what has been normalized in REST APIs, but it's not user friendly AND it's OP's whole point. He built his entire article -- and apparently his APIs -- around avoiding 404 ambiguity. If you hit an endpoint and get a 404... did you do it wrong? Is my documentation outdated? Even better: What recourse do you have? how do you figure out the answer? Your only recourse is to email me. Send me cURL commands and screenshots and sit on your thumbs until I write back. IMHO the REST folk were blinded by the existing 404 normalcy set up by web servers. ... personally I think OP's idea isn't great. I think returning 200 and making me parse the response and hoping it's consistent between services is too much work compared to the simplicity of the HTTP response. Instead, I'd change the default from 404 to 501. HTTP 501 - not implemented (URI is not working)
HTTP 404 - resource not found (Joe doesn't exist in db)
|
|
So instead of
You sent Then if the actual procedure name was "get_employees", the correct response to this request would be 501, and /1000 referring to a non-existent employee would be a 404.If making an RPC and restricting yourself to the known HTTP methods, the closest is
which would return 404 only if the controller endpoint didn't exist, and would return whatever the application wanted if userid=100 didn't exist, such as 422 or 200 with a response indicating non-existence. It would be just like a local procedure call that could return a false value, or throw an exception instead of returning a value.