Adding networks to existing templates via API

Solved
genesisjoec
Conversationalist

Adding networks to existing templates via API

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
DexterLaBora
Meraki Employee
Meraki Employee

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

DexterLaBora_1-1636980405922.png

 

 

Then "Run" the collection.

DexterLaBora_2-1636980699149.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

 

 

DexterLaBora_4-1636981726692.png

 

 

Runner demo - bind network.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 )

DexterLaBora_3-1636981621408.png

 

 

Hope this helps!

 

View solution in original post

3 Replies 3
DexterLaBora
Meraki Employee
Meraki 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

 

 

 

DexterLaBora
Meraki Employee
Meraki Employee

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

DexterLaBora_1-1636980405922.png

 

 

Then "Run" the collection.

DexterLaBora_2-1636980699149.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

 

 

DexterLaBora_4-1636981726692.png

 

 

Runner demo - bind network.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 )

DexterLaBora_3-1636981621408.png

 

 

Hope this helps!

 

genesisjoec
Conversationalist

Very much appreciative. Thank you both!

Get notified when there are additional replies to this discussion.