Python Forum
API call returning list value of 'None' - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: API call returning list value of 'None' (/thread-19107.html)



API call returning list value of 'None' - jimbone30 - Jun-13-2019

From a GUI, I can verify that there's data available.
However, I'm trying to pull a history of data from a probe, and when I make the call, I keep getting a return of 'None'.

{'results': [{'series': [None], 'time_ms': 1560326400000},
{'series': [None], 'time_ms': 1560330000000},
{'series': [None], 'time_ms': 1560333600000},
{'series': [None], 'time_ms': 1560337200000},
{'series': [None], 'time_ms': 1560340800000}]}

I've got a print statement that makes me feel like I'm sending in the right data, but the output suggests otherwise.
Some additional troubleshooting items I can add? Any suggestions appreciated.


RE: API call returning list value of 'None' - buran - Jun-13-2019

for start - showing your code (in python tags) would be helpful. best would be minimal example that reproduce the error (i.e. no GUI part, etc)


RE: API call returning list value of 'None' - jimbone30 - Jun-14-2019

@buran, thanks. hopefully this helps. I put a * for some of the items.

import time
import samsara
from samsara.rest import ApiException
from pprint import pprint
import time, datetime
#
group_id = *
#Date and time (your time zone): Tuesday, June 11, 2019 1:00:00 PM GMT-04:00
start_ms = 1560333600000
#Date and time (your time zone): Tuesday, June 11, 2019 6:00:00 PM GMT-04:00
end_ms = 1560344400000
#3600000 will return data at hour intervals
step_ms = 3600000
series = [{"field":"probeTemperature","widget_id":212014918280113}]
#
api_instance = samsara.DefaultApi()
access_token = '#' # str | Samsara API access token.
history_param = samsara.HistoryParam(group_id, start_ms, end_ms, step_ms, series) # HistoryParam | Group ID, time range and resolution, and list of sensor ID, field pairs to query.
#print(history_param)

try: 
    # /sensors/history
    api_response = api_instance.get_sensors_history(access_token, history_param)
    pprint(api_response)



RE: API call returning list value of 'None' - buran - Jun-14-2019

well, your code is more or less identical to the example. The only major difference I see is they instanciate SamsaraClient and you - DefaultApi. Not familiar with the package/this API, but did you try with the example?


RE: API call returning list value of 'None' - jimbone30 - Jun-14-2019

thanks @buran, I was going off this:
https://github.com/samsarahq/samsara-python/blob/master/docs/DefaultApi.md#get_sensors_history

(I appreciate the formatting above - new to the forum)


RE: API call returning list value of 'None' - jimbone30 - Jun-14-2019

the print didn't work, but history.results has data, which is really all I needed.
thanks!