Beginner API help

Jwiley78
Building a reputation

Beginner API help

I've been working on this short course:  https://developer.cisco.com/learning/lab/meraki-02-dashboard-api/step/5

 

I can't seem to get the network ID to work.  Anyone know a good video or other links that might be more helpful?

3 REPLIES 3
Bruce
Kind of a big deal

Step 3 should’ve shown you that. Step 3 calls an API that lists all the networks in the organisation. Then you should’ve selected the ID for the DevNetLab network and stored it in the environment variable ‘networkId’. This environment variable is then what’s used in Step 4 to list the clients on the network, and again in Step 5 to list the network information.

Edgar-VO
Building a reputation

Piece of python to get all your networks (values in my_net)
 
-----------------------------------------------------
 
import meraki
 
api_key = "Your API key"
 
dashboard = meraki.DashboardAPI(api_key)
 
my_org = dashboard.organizations.getOrganizations()
 
for org in my_org:
        org_id = org['id']
        print(org['name'])
 
 
my_networks = dashboard.organizations.getOrganizationNetworks(org_id)
 
for my_net in my_networks:    
       print(my_net)

 

--------------------------------------------------------

 

KnockAroundGuy
Just browsing

If you are using Postman to pull this information verses with Python there are a couple things that you will want to do.
Get familiar with setting up your environmental settings. Once you set these you will not need to add this to your requests anymore.

KnockAroundGuy_0-1622506423033.png

In your example if you already have the organizationId and set it and your key, url in your environmental variables you should be able to run that GET command {{baseUrl}}//organizations/{{organizationId}}/networks

If you go to the response body in Postman you will see the output of all your networkIds.

After that you can go one step further and pull data by either exporting those to a csv or manually defining on as a variable.


Defining the {{networkId}} variable can be set at the get / put level in your Params table or in your environmental if you are only working on one network or you can utilize Runner inside Postman to iterate through a cvs file that contains your networkIds. 

 

{{baseUrl}}/networks/{{networkId}}/appliance/vlans/


Your cvs will look like;

           Column A
Row 1 networkid
Row 2 L_<your-networkId>
Row 3 L_<your-next-networkId>
Row 4 and so on

In the csv below I only have two networks in that list which were the only ones I needed to update.

KnockAroundGuy_0-1622508193897.png

 



You can open runner select your csv file and it will show you the number of lines it will iterate through you can click the preview button and see the list of your networkIds. These will become your variable {{networkId}}

Feel free to message me if this seems helpful or you have a question around it.

Get notified when there are additional replies to this discussion.