Skip to content
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

API returns HTML for 404s #421

Open
torotil opened this issue Jan 9, 2024 · 1 comment
Open

API returns HTML for 404s #421

torotil opened this issue Jan 9, 2024 · 1 comment

Comments

@torotil
Copy link
Contributor

torotil commented Jan 9, 2024

The API documentation says:

All calls return JSON, and you can generally get an HTML representation by adding .html on the end.

and

Whenever an error is returned from MapIt, it is as a dictionary with an error key …

but for example https://mapit.mysociety.org/postcode/F-54110 returns a HTML page.

@dracos
Copy link
Member

dracos commented Jan 11, 2024

It does return JSON for something that looks like a postcode but doesn't exist. We should probably have a default fallback for the endpoint locations to JSON, just for consistency, though we hope API users will do what they can to reduce unnecessary API calls being made. In this case, it hasn't actually reached the postcode endpoint with that URL, because it hasn't got past the basic check in the router, hence it being treated as a normal web page. The API does sort of assume you are doing some minimal form of checking of the data you're going to send before being sent (e.g. stripping out non-alphanumerics, perhaps even checking it's the right format for a postcode ideally).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants