I am very new to the Meraki API, and am trying to get the latency for a specific device, but when I ran the request it returns an empty list, even though the response is 200. I'm not sure what I am doing wrong. Here's my code:
Hi there,
I think you require also the timespan as a parameter. I use the same calls with API in python. I get the right result.
I put a part of my python code in it... Maybe you can use it.
On small addition....
with the line added
You'll also need to convert the reply, since it is returning an object with json. Try including this;
import json
from pprint import pprint
[...]
r = requests(...)
if r.status_code == 200:
rjson = r.json()
pprint(rjson)
else:
raise SystemExit(f"Unexpected status code {r.status_code}")
actually, there is no need for that...
If you do a
print(my_latency_results)
Then you get all the results
If you use
my_latency = my_latency_results[-1]
print(my_latency) then you get the latest result which might look like this
{ "startTime": "2018-10-09T22:20:27Z", "endTime": "2018-10-09T22:21:27Z", "lossPercent": 0, "latencyMs": 44 } ]
and the latency = my_latency['latencyMs']
and loss will be : loss = my_latency['lossPercent']