Reputation: 8582
If I have a service running with a url pattern similar to below.
HOST/animals/{id}
If do a GET on this url with a non existent id for most Rest implementations I would expect to receive a 404 Not Found response.
If I do a GET request for (note the typo!):
HOST/animels/{id}
With a valid id I will also get a 404 response in most Rest implementations.
Obviously I can distinguish between the scenarios by looking in the response body but this would be custom behaviour for my API.
Is there an standard approach to this?
Maybe return method not allowed/bad request for non mapped urls (though this would be large change to expected behaviour)?
Or do we need 2 status codes for Not Found?
A scenario for something like this occurring is a typo in some documentation/implementation of a client.
Upvotes: 2
Views: 53
Reputation: 1948
If you treat the entire URL as an identifier that points to a resource, the two cases are the same.
Thus both cases should be treated the same as 'NOT Found'
Upvotes: 1