Python Forum
API call returning list value of 'None'
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
API call returning list value of 'None'
#1
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.
Reply
#2
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)
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
@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)
Reply
#4
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?
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#5
thanks @buran, I was going off this:
https://github.com/samsarahq/samsara-pyt...rs_history

(I appreciate the formatting above - new to the forum)
Reply
#6
the print didn't work, but history.results has data, which is really all I needed.
thanks!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  list.sort() returning None SmallCoder14 8 403 Mar-19-2024, 09:49 PM
Last Post: SmallCoder14
  for loops break when I call the list I'm looping through Radical 4 823 Sep-18-2023, 07:52 AM
Last Post: buran
  How do I call sys.argv list inside a function, from the CLI? billykid999 3 752 May-02-2023, 08:40 AM
Last Post: Gribouillis
  returning a List of Lists nafshar 3 1,014 Oct-28-2022, 06:28 PM
Last Post: deanhystad
  How to create a linked list and call it? loves 12 4,356 Nov-22-2020, 03:50 PM
Last Post: loves
  list call problem in generator function using iteration and recursive calls postta 1 1,862 Oct-24-2020, 09:33 PM
Last Post: bowlofred
  2d List not returning DariusKsm 2 1,644 Sep-22-2020, 05:11 PM
Last Post: DariusKsm
  How to call/read function for all elements in my list in python johnny_sav1992 1 2,038 Jul-27-2020, 04:19 PM
Last Post: buran
  Need help returning min() value of list? edwdas 3 2,008 Nov-10-2019, 09:43 PM
Last Post: snippsat
  Call and execute methods from a list asheru93 2 2,275 Jan-17-2019, 08:31 AM
Last Post: asheru93

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020