Back to Smartcitizen.me

API 500 Response internal server error - Please investigate

Hello, I am getting “Internal Server Error” status code 500 when calling historical readings from the API as per these examples, although I am including my Oauth API key in the actual requests, the result is the same:

https://api.smartcitizen.me/v0/devices/13777/readings?sensor_id=7&rollup=4h&from=2021-12-20&to=2021-12-25

https://api.smartcitizen.me/v0/devices/14443/readings?sensor_id=7&rollup=4h&from=2021-12-20&to=2021-12-25

This is affecting an application I have built which shows a visual display of recent data, which was previously working…! I think the issue started late November or early December.

Thanks

Hi!

Seems that the requests for the sensors in these devices are invalid. Checking the sensors available in each device, seems like they do not contain any sensor which sensor_id = 7 . This should yield a invalid request instead of a 500, though.

You can check the sensor ids available in the data>sensors field in the request to the https://api.smartcitizen.me/v0/devices/14443/ endpoint. It is safer to only request the data that appears there.

thanks!

Many thanks for the quick reply. Those were sleepy, poor examples, I had forgotten about the differing sensor ids, sorry.

I have found an error in my code that creates the dates for the request that caused my issue. I had jumped on the returned 500 code before actually looking at my api calls as it had been working fine up until December! All fixed and working again now.

Perhaps the main issue here is that it is returning 500, when that isn’t appropriate.

Thanks again for your time.

2 Likes

No problem! Glad it’s working again!