PYTHON - get_network_traffic_shaping - HTTP response not OK.

Solved
cgarrido
Conversationalist

PYTHON - get_network_traffic_shaping - HTTP response not OK.

I'm trying to use get_network_traffic_shaping, however whenever I call the function I'm getting a "HTTP response not OK."

#! /usr/bin/env python3
from meraki_sdk.meraki_sdk_client import MerakiSdkClient
from meraki_sdk.exceptions.api_exception import APIException
def init():
x_cisco_meraki_api_key = 'REDACTED'
meraki = MerakiSdkClient(x_cisco_meraki_api_key)
return meraki
def trafficShaping(meraki, network_id):
traffic_shaping_controller = meraki.traffic_shaping
try:
result = traffic_shaping_controller.get_network_traffic_shaping(network_id)
return result
except APIException as e:
print(e)
if __name__ == '__main__':
try:
meraki = init()
test_shaping = trafficShaping(meraki, 'NETWORK_ID')
print(test_shaping)
except KeyboardInterrupt:
print('Program terminated.')

 

1 Accepted Solution
chengineer
Meraki Alumni (Retired)
Meraki Alumni (Retired)

Two separate things here:
1. It looks like you moved over to the new Python library since your original post (which in the source there uses the deprecated SDK), so that's good. This library is easier and more intuitive to use.


2. Just like in dashboard UI, the "traffic shaping" page change significantly for a network that is bound to template, you cannot make the GET call here since the settings live on the parent template. If you change the network ID to be the configuration template's ID, you'll get back the traffic settings as dictated by the template.

Solutions Architect @ Cisco Meraki | API & Developer Ecosystem

View solution in original post

5 Replies 5
PhilipDAth
Kind of a big deal
Kind of a big deal

How confident are you that the "NETWORK_ID" that you are using is correct?

cgarrido
Conversationalist

Thanks for the reply. I think I'v been able to figure it out. I was able to verify that the network_id was correct, however when I generated a log file I received the following:

2020-03-09 08:56:12 meraki: ERROR > Traffic shaping, getNetworkTrafficShaping - 400 Bad Request, {'errors': ['Unsupported for networks bound to a template']}

Meraki_John
Meraki Employee
Meraki Employee

Hey @cgarrido !

 

Similar to what @PhilipDAth said.

 

I chucked your code in to an environment to test, and it works fine for me.

 

It's more likely to be an issue with your key, rather than your network ID (but check both).

 

Cheers!

John

cgarrido
Conversationalist

Similar to my other response it looks like the traffic_shaping call didn't work with a network I had bound to a template. Thank you for the response!

chengineer
Meraki Alumni (Retired)
Meraki Alumni (Retired)

Two separate things here:
1. It looks like you moved over to the new Python library since your original post (which in the source there uses the deprecated SDK), so that's good. This library is easier and more intuitive to use.


2. Just like in dashboard UI, the "traffic shaping" page change significantly for a network that is bound to template, you cannot make the GET call here since the settings live on the parent template. If you change the network ID to be the configuration template's ID, you'll get back the traffic settings as dictated by the template.

Solutions Architect @ Cisco Meraki | API & Developer Ecosystem
Get notified when there are additional replies to this discussion.