Valid requests to sensor network endpoints return 400 Bad Request and JSON error if there are no matching results
Opened this issue · 0 comments
Requests against sensor network endpoints, like sensor-networks/array_of_things_chicago/features
or sensor-networks/array_of_things_chicago/sensors
, return a 400 Bad Request header and an error JSON response if they fail to find any matching items. Example, in the middle of the lake:
http://plenar.io/v1/api/sensor-networks/array_of_things_chicago/sensors?geom=%7B%22type%22%3A%22Feature%22%2C%22properties%22%3A%7B%7D%2C%22geometry%22%3A%7B%22type%22%3A%22Polygon%22%2C%22coordinates%22%3A%5B%5B%5B-87.40533828735352%2C42.44778143462245%5D%2C%5B-87.40533828735352%2C42.601619944327965%5D%2C%5B-86.49347305297852%2C42.601619944327965%5D%2C%5B-86.49347305297852%2C42.44778143462245%5D%2C%5B-87.40533828735352%2C42.44778143462245%5D%5D%5D%7D%7D
This is in contrast to the event/shape endpoints, which return a success with an empty array of objects, and is also an incorrect application of the 400 status code because there was nothing wrong with the client's request. We just don't have any results to give them.
This is driving a significant amount of custom handling in the Explorer redesign, and masks any actual failures since we're having to swallow all of these AJAX errors.