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()
Solved! Go to solution.
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.
Did this work before? Did you make many requests in a row?
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.
Thank you for the sanity check. Much appreciated.
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.