You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.
When I request for https://dev.riskopendata.org/api/dataset/?country=undefined (not an ID) or https://dev.riskopendata.org/api/dataset/?country= (absent ID) or https://dev.riskopendata.org/api/dataset/?country=9999 (unexisting ID), the API returns a 200 response.
I expect it to return a 404 when the country does not exist in the database.
I expect it to return a 200 with an empty array if the country exists but there is not data.
I expect it to return a 200 with array items if the country exists and data exists
The text was updated successfully, but these errors were encountered:
This is not a bug but was by design. It's a REST API so 404 is sent back if the API url does not exist, not if the resource doesn't.
You are calling a proper endpoint so a 200 is returned. In the json you should then get the error and the reason why (or an empty dataset, depending on the API design). It's an application error what you are looking for, not an HTTP protocol one (which instead raises 404, 500 and so on).
REST is resource oriented indeed. My understanding, in term of software design, is when requesting a resource (at a given URL):
200: resource is found, resource exists
404: resource is not found, there is nothing matching a primary identifier
Having a response with an empty array and a 200 status code is ambiguous in the situation you describe:
resource is found and there is an empty list of element associated to it
resource does not exist, an empty list of element is the proof it does not exist
Maybe my expectation is more aligned with api/dataset/:country, country being optional.
If we consider this application, https://dev.riskopendata.org/dataset_details.html?keyds=9999 is the main page requesting data to the api/dataset/; keyds is a requirement. The first 3 URL shared in this issue are derived from actual use case of frontend URL (#350 made me open the issue we are currently discussing).
I expect it to return a 404 when the country does not exist in the database.
I expect it to return a 200 with an empty array if the country exists but there is not data.
I agree with you if the API offer a specialization of the country as part of the URI, not as a filter as it is now.
If we need this feature we can think to change the API accordingly.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
When I request for
https://dev.riskopendata.org/api/dataset/?country=undefined
(not an ID) orhttps://dev.riskopendata.org/api/dataset/?country=
(absent ID) orhttps://dev.riskopendata.org/api/dataset/?country=9999
(unexisting ID), the API returns a 200 response.The text was updated successfully, but these errors were encountered: