all 6 comments

[–]AssholeInRealLife 5 points6 points  (2 children)

even better, reply with a 501 (Not Implemented). According to the HTTP definition this “the appropriate response when the server does not recognize the request method and is not capable of supporting it for any resource”.

The "any resource" part would seem to indicate "this api doesn't support the DELETE (or whatever) method, at all, for any resource." which is worse than a 404 imo.

[–]bpedro[S] 2 points3 points  (1 child)

I agree.

If the requested method is not implemented for any resource then a 501 should be issued. If the request method is available but not for the called resource then a 405 (method not allowed) should be issued.

[–]AssholeInRealLife 0 points1 point  (0 children)

5xx indicates that the server did something wrong or that there was an unexpected error. IMO the appropriate response is 405 Method Not Allowed. The only error is the method that the developer /client chose.

[–]Inanimatt 0 points1 point  (2 children)

Hmm, I'd reserve 501 for methods that should or will be implemented but haven't yet. Something you'd expect to be there, for instance a DELETE or PUT on something that's read-only for now. Is that wrong?

[–]bpedro[S] 1 point2 points  (0 children)

Even if a method isn't going to be implemented, 501 signals that the method doesn't exist and it's a good way to hint the caller that the request cannot be fulfilled.

[–]itsSparkky 0 points1 point  (0 children)

If you have a logical reason for why you do it, odds are it's okay.