cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
5798
Views
4
Helpful
3
Replies

Adding networks to existing templates via API

genesisjoec
Community Member

I'm researching the best method to add hundreds of networks split between two templates within an organization. The networks already exist in the organization and just need to be sync'd to a template to receive their configuration. I see in Postman that I can execute a put to update a configuration template. I'm thinking the best method to make the change is by using json in the body of the call, but I'm not certain of the syntax to use. In truth, I'm not certain that's even the correct call to use, to make a change of this type. Any help is appreciated. Please let me know if further explanation is needed.

Thanks!

1 Accepted Solution

Accepted Solutions

For a Postman solution to this, you could use the Runner tool to import a CSV or JSON file with a list of IDs to act as variables for each run of the request.

Start by creating a new Collection for this Runner group

- Copy in the "Bind a network to a template" endpoint into your new collection. (delete any existing headers)

- The POST body should look like this

{
    "configTemplateId": "{{configTemplateId}}"
}

- Add a Tests script for better logging

pm.test("Status code is 201", function () {
    pm.response.to.have.status(201);
});

- Make sure your environment has an {{apiKey}} variable set

- Make sure your Collection has the following Authorization config

image.png

Then "Run" the collection.

image.png

Upload a csv file with two columns and a row for each networkId and its desired configTemplateId or a JSON file with an array with the those params for each network.

Set the Delay to about 250ms


file.csv


networkId,configTemplateId
L_6434517960000001,N_111111111
L_6434517960000002,N_111111111
L_6434517960000003,N_111111111
L_6434517960000004,N_222222222
L_6434517960000004,N_222222222

image.png

image.png

This will run the desired API for each network, binding it to the config template. You will get a report of each request so you have a log of what worked or had issues.



example summary (using Blink the LEDs )

image.png

Hope this helps!

View solution in original post

3 Replies 3

DexterLabora
Cisco Employee
Cisco Employee

First get a list of all of your network IDs

https://developer.cisco.com/meraki/api-v1/#!get-organization-networks

You will then need to bind each network to a configuration template.

https://developer.cisco.com/meraki/api-v1/#!bind-network

If this will be a lot of API requests, then I would suggest using action batches for this.

https://developer.cisco.com/meraki/api-v1/#!action-batches-overview/use-cases

For a Postman solution to this, you could use the Runner tool to import a CSV or JSON file with a list of IDs to act as variables for each run of the request.

Start by creating a new Collection for this Runner group

- Copy in the "Bind a network to a template" endpoint into your new collection. (delete any existing headers)

- The POST body should look like this

{
    "configTemplateId": "{{configTemplateId}}"
}

- Add a Tests script for better logging

pm.test("Status code is 201", function () {
    pm.response.to.have.status(201);
});

- Make sure your environment has an {{apiKey}} variable set

- Make sure your Collection has the following Authorization config

image.png

Then "Run" the collection.

image.png

Upload a csv file with two columns and a row for each networkId and its desired configTemplateId or a JSON file with an array with the those params for each network.

Set the Delay to about 250ms


file.csv


networkId,configTemplateId
L_6434517960000001,N_111111111
L_6434517960000002,N_111111111
L_6434517960000003,N_111111111
L_6434517960000004,N_222222222
L_6434517960000004,N_222222222

image.png

image.png

This will run the desired API for each network, binding it to the config template. You will get a report of each request so you have a log of what worked or had issues.



example summary (using Blink the LEDs )

image.png

Hope this helps!

genesisjoec
Community Member

Very much appreciative. Thank you both!