11-14-2020 05:02 PM
Hello!
I am studying for DevNet associate and trying out the Meraki SDK on the DevNet SandBox. I am using the provided Dashboard API Key, however when trying to perform a PUT/update it returns a 403. I tried generating a API key from dashboard myself, but that returned a different list of Organizations. Am I missing something obvious? Any help would be appreciated!
Code sample: Error out with 403 on "meraki.vlans.update_network_vlan(updated_vlan)"
from meraki_sdk.meraki_sdk_client import MerakiSdkClient
from pprint import pprint
import json
token = 'SandboxToken'
# Create a new SDK client
meraki = MerakiSdkClient(token)
# Just an HTTP request to grab all Orgs
orgs = meraki.organizations.get_organizations()
pprint(orgs)
for org in orgs:
if org['name'] == "DevNet Sandbox":
orgId = org['id']
params = {}
params['organization_id'] = orgId
# Get all of a specific orgs networks
orgNetworks = meraki.networks.get_organization_networks(params)
pprint("-----------------Organization Networks-----------------")
pprint(orgNetworks)
for network in orgNetworks:
if network['name'] == "DevNet Sandbox ALWAYS ON":
netId = network['id']
pprint("-----------------Network ID-----------------")
pprint(netId)
# Get all of a specific Orgs specific networks vlans
vlans = meraki.vlans.get_network_vlans(netId)
pprint("-----------------VLANS-----------------")
pprint(vlans)
# Check the postman documentation for Cisco Meraki to understand.
# update_network_vlan requires two parameters (netId, vlanId) as well as an optional third paramter, which an object with the data you want to update
vlan = vlans[0]
vlan['name'] = "DevNet Tests"
updated_vlan = {}
updated_vlan['network_id'] = netId
updated_vlan['vlan_id'] = vlan['id']
updated_vlan['update_network_vlan'] = vlan
pprint("-----------------DICT TO SEND-----------------")
pprint(updated_vlan)
result_update_vlan = meraki.vlans.update_network_vlan(updated_vlan)
pprint("-----------------UPDATE RESULT-----------------")
result_get_vlans = meraki.vlans.get_network_vlans(netId)
pprint("-----------------UPDATE VERIFY-----------------")
pprint(result_get_vlans)
11-16-2020 11:54 PM
Hi
Considering you have the correct API .. there is no network named "DevNet Sandbox ALWAYS ON" under ORG "DevNet Sandbox". Logged in to Meraki with username - devnetmeraki@cisco.com and password - i*******aki
Maybe it was deleted or something ... try recreating the network with a MX device to modify VLAN name.
The overall script is ok and it works if the network exists in the ORG.
11-17-2020 01:53 AM
Hey there, always on sandbox is read-only - you will be able to auth and get information - but not make changes. To do this, you would need to use the reservable sandbox's.
Hope this helps.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide