Hi,
I'm using this API call using python:
import requests
import json
url = "https://api.meraki.com/api/v1/organizations"
payload={}
headers = {
'X-Cisco-Meraki-API-Key': 'xxxxxxxxxx
response = requests.request("GET", url, headers=headers, data=payload)
r = json.loads(response.text)
for organizations in r:
print(organizations['name'] + ' ' + organizations['id'])
The output is what I'm looking for.
What I need to do now is to be able to use the organization id to then call all the networks in each org:
eg.....
API CALL 1....url = "https://api.meraki.com/api/v1/organizations"
(THIS WILL PRINT OUT ALL ORGS I HAVE ACCESS TO)
Then use these ID's in the next calls until no ID's are left...
If you use the Meraki Dashboard API library:
https://developer.cisco.com/meraki/api-v1/
Then you can use some code like this:
# Search for the org
orgs = dashboard.organizations.getOrganizations()
for org in orgs:
if org['name'] == orgName:
orgId=org['id']
break;
if orgId == None:
print("Invalid organization name supplied: "+orgName)
exit(-1)
If I run this after the 1st API call it fails:
orgs = dashboard.organizations.getOrganizations()
NameError: name 'dashboard' is not defined
I'm just not sure how to link the API query with this and then use it for the 2nd query.
Thanks
Sam
If this is the script that calls the ORG names:
#SCRIPT THAT CALLS THE ORGS THEN ONLY PRINTS THE ORG NAME ONLY
import requests
import json
url = "https://api.meraki.com/api/v1/organizations"
payload={}
headers = {
'X-Cisco-Meraki-API-Key': 'xxxx'
}
response = requests.request("GET", url, headers=headers, data=payload)
r = json.loads(response.text)
for organizations in r:
print(organizations['name'])
Where does the create session from below get inserted?
@sambo the suggestions above are correct and rely on installing and using the Python SDK.
Please read the Python SDK readme for instructions: https://github.com/meraki/dashboard-api-python
I'm reading and learning now, Thanks!
Sam