cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Do parameters with API calls have to be a dictionary data type when calling device performance?

Highlighted
Conversationalist

Do parameters with API calls have to be a dictionary data type when calling device performance?

I am trying to retrieve my devices performance with the python api call 

result = devices_controller.get_network_device_performance(collect)

For some reason when I populate the collect dictionary and call this api I get the error: 

 

raise APIException('HTTP response not OK.', context)
meraki.exceptions.api_exception.APIException: HTTP response not OK.

But when I convert the dictionary (collect) to a string I get no error, but also no performance data

What could be causing this error and what other approaches could I use to try and get the performance data from the network devices.

 

Many Thanks!

 

 

4 REPLIES 4
Conversationalist

Re: Do parameters with API calls have to be a dictionary data type when calling device performance?

They need to be JSON.

Conversationalist

Re: Do parameters with API calls have to be a dictionary data type when calling device performance?

Could you please expand on this?

The code is from meraki: here

The code works for a section of devices and networks but then stops and throws the error in my original question

Here to help

Re: Do parameters with API calls have to be a dictionary data type when calling device performance?

I've worked through this example with the Python SDK and can't reproduce your error.  It might help if we could see the HTTP response that is considered invalid - that should give us some more clues.  Can you catch the exception and display the context?  I'm not sure what format the context takes, I'd try all these:

 

try:
 result = devices_controller.get_network_device_performance(collect)
catch APIException as e:
  print(e)
  print(e.context)
  print(e['context'])
Here to help

Re: Do parameters with API calls have to be a dictionary data type when calling device performance?

I can't tell if the error is related to the content you're sending, or in parsing the response.

 

I've been doing this to send dicts using the requests module:

payload = {
           "roomId": roomId,
           "personId": personId
          }
resp = requests.post(..., payload = payload)

 

I've been doing this to convert my HTTP responses into Python-native dicts:

response = requests.get(url, headers=headers)

#This is a string
type(response.text)

import json
res = json.loads(response.text)

#This is now a dict
type(res)

 

Welcome to the Meraki Community!
To start contributing, simply sign in with your Cisco account. If you don't yet have a Cisco account, you can sign up.