-
Notifications
You must be signed in to change notification settings - Fork 252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrongly returns a 404 status code #69
Comments
Returning 404 is the intent This particular API was created when "RESTful" interfaces were in vogue. Although there is no formal spec for designing these types of APIs, my understanding is that it's generally considered a good idea to make full use of the available range of HTTP status codes to accurately relay information about the nature of a request. When requesting a resource (like in this case, a postcode) it's common to return a 404 response code if that resource does not exist. A good indicator that you're dealing with a resource is if the URI looks something like I don't think postcodes.io is in the minority here, most HTTP API's designed within the last ~5 years take a similar approach. The Ruby on Rails framework, which is built around RESTful ideas, returns 404 by default for a non existent resource. Likewise (afaik) many popular REST API's like Twitter and Stripe exhibit similar behaviour. However, if you were performing a query like It's only |
Sounds right. |
if you go to http://api.postcodes.io/postcodes/s62%205ty it correctly returns a result of 'postcode not found' but has a 404 status code. Not sure if this is just a mistake or a misunderstanding of what a 404 status code means.
If the communication with the server was successful, regardless of whether results were found it should return a 200 status code.
The text was updated successfully, but these errors were encountered: