LatencyStats- 404

Solved
Jamieinbox
Getting noticed

LatencyStats- 404

This is not working for me. Why not? (& thank you).

Here is the API call:
/devices/{serial}/wireless/latencyStats
Get Device Wireless Latency Stats - Meraki Dashboard API v1 - Cisco Meraki Developer Hub

Error occurred during API call: 400 Client Error: Bad Request for url (Real SN is used): https://api.meraki.com/api/v1/devices/AAAA-BBBC-DDDD/wireless/latencyStats

Here's my full code:

import requests

BASE_URL = 'https://api.meraki.com/api/v1/'

def get_api_key():
return input("Enter your Meraki API key: ")

def get_latency_stats(api_key, serial):
headers = {
'X-Cisco-Meraki-API-Key': api_key,
}
try:
response = requests.get(BASE_URL + f'devices/{serial}/wireless/latencyStats', headers=headers)
response.raise_for_status() # Raise an exception for unsuccessful API calls
return response.json()
except requests.exceptions.RequestException as e:
print(f"Error occurred during API call: {e}")
return {}

def main():
api_key = get_api_key()
serial = input("Enter the serial number of the device you want latency stats for: ")

latency_stats = get_latency_stats(api_key, serial)
if latency_stats:
print("Latency Stats:")
print(latency_stats)

if __name__ == "__main__":
main()

1 Accepted Solution
PhilipDAth
Kind of a big deal
Kind of a big deal

Looking at the developer documentation:
https://developer.cisco.com/meraki/api-v1/get-device-wireless-latency-stats/ 

Their example header (click on "Python" on the right hand side) is quite different to yours:

 

headers = {
    "Authorization": "Bearer xxx",
    "Accept": "application/json"
}

 

 If that still doesn't work, maybe start by copying the example code, verify that works, and slowly morph it into what you want.

View solution in original post

6 Replies 6
alemabrahao
Kind of a big deal
Kind of a big deal

Did this work before? Did you make many requests in a row?

I am not a Cisco Meraki employee. My suggestions are based on documentation of Meraki best practices and day-to-day experience.

Please, if this post was useful, leave your kudos and mark it as solved.

I haven't been able to get it to work yet. I'm trying to get stats on one AP serial number and then go from there.

Is the serial number correct? Is the device online?

 

Everything seems to be fine with your script, so if the answer is yes to both questions, I suggest you open a support case.

I am not a Cisco Meraki employee. My suggestions are based on documentation of Meraki best practices and day-to-day experience.

Please, if this post was useful, leave your kudos and mark it as solved.

Thank you for the sanity check. Much appreciated.

 

PhilipDAth
Kind of a big deal
Kind of a big deal

Looking at the developer documentation:
https://developer.cisco.com/meraki/api-v1/get-device-wireless-latency-stats/ 

Their example header (click on "Python" on the right hand side) is quite different to yours:

 

headers = {
    "Authorization": "Bearer xxx",
    "Accept": "application/json"
}

 

 If that still doesn't work, maybe start by copying the example code, verify that works, and slowly morph it into what you want.

Large data dump- but that worked. Thank you.

Get notified when there are additional replies to this discussion.