401 Unauthorized, {'errors': ['Invalid API key']} /networks/{networkId}/appliance/vlans/{vlanId}

Joe-morris
Conversationalist

401 Unauthorized, {'errors': ['Invalid API key']} /networks/{networkId}/appliance/vlans/{vlanId}

Hello, I am trying to get a list of vlan information (specifically looking for the fixed ip assignments)  from all networks. Starting with trying to use API to get the info for a single vlan on a single network.

 

I am using the template from https://developer.cisco.com/meraki/api-v1/#!get-network-appliance-vlan using the Meraki Python Library.


My API key which has full access to the dashboard and is being used for several scripts that work. When I try the below I get a 401 error.

 

>>> import meraki
>>> API_KEY = '{MY_API_KEY deleted}'
>>> organization_id = '{MY ORG ID delteed}'
>>> dashboard = meraki.DashboardAPI(API_KEY)

>>> network_id = '{removed network ID}'
>>> vlan_id = '10'
>>> response = dashboard.appliance.getNetworkApplianceVlan(network_id, vlan_id)
2022-07-21 08:25:17 meraki: INFO > GET https://api.meraki.com/api/v1/networks/{removed network ID}/appliance/vlans/10
2022-07-21 08:25:18 meraki: ERROR > appliance, getNetworkApplianceVlan - 401 Unauthorized, {'errors': ['Invalid API key']}
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.9/site-packages/meraki/api/appliance.py", line 1369, in getNetworkApplianceVlan
return self._session.get(metadata, resource)
File "/usr/local/lib/python3.9/site-packages/meraki/rest_session.py", line 284, in get
response = self.request(metadata, 'GET', url, params=params)
File "/usr/local/lib/python3.9/site-packages/meraki/rest_session.py", line 278, in request
raise APIError(metadata, response)
meraki.exceptions.APIError: appliance, getNetworkApplianceVlan - 401 Unauthorized, {'errors': ['Invalid API key']}
>>>

 

With the same above If I use the below command, I can get a list of my networks...

 

>>>>networks = dashboard.organizations.getOrganizationNetworks(
... organization_id, total_pages='all')

>>>>print(networks)

 

So I know the API key is valid. What am I missing?

 

3 Replies 3
RaphaelL
Kind of a big deal
Kind of a big deal

Just tried the endpoint on my Org and networks and it is working. 

 

Is there any MX on that network ? if not it should return a 404 and not a 401 , but it might be bugged. 

Joe-morris
Conversationalist

Turns out I'm an idiot. I was hammering the wrong networkID. No clue how I got it. But i ended up with blinders on focused on the wrong damn networkid. Tried another that I pulled from the "networks" API and it works as expected. Been a long week, all

RaphaelL
Kind of a big deal
Kind of a big deal

Happens to the best of us ! Glad you were able to find a solution ! 

Get notified when there are additional replies to this discussion.