Add Meraki VLAN via API failing

DanP
New here

Add Meraki VLAN via API failing

Hi,

 

New to the Meraki community and was hoping to get some assistance.

 

Trying to add a new VLAN via postman and request is just sitting there and not going anywhere. It is not returning any error and I am also not seeing any logs in the dashboard on the network,

 

Has anyone had issues with the add VLAN API post and if so could you share what was done to get it working.

 

Thanks

14 REPLIES 14
PhilipDAth
Kind of a big deal
Kind of a big deal

This is outside my area, but take a look at this example on GitHub that allows you to export and import configurations.

https://github.com/meraki/automation-scripts/blob/master/copymxvlans.py

 

You can jump to the procedure called "createvlan".

Thanks for the reply. Probably shoud have mentioned this is for a Layer Interface on an MS350.

 

I have just had a look at the script and that seems to be for an MX unless it is the same for an MS. Interesting thing is I have had a look on https://documenter.getpostman.com/view/897512/meraki-dashboard-prov-api/2To9xm#intro and the body looks different.

 

Am thinking maybe the postman Meraki Dashboard API is not up to date and I am not passing the correct variables hence it is failing.

PhilipDAth
Kind of a big deal
Kind of a big deal

Log into the dashboard, and then [in the top right hand corner] go "Help/API Docs".  That should be the most accurate reference.

colo
Meraki Alumni (Retired)
Meraki Alumni (Retired)

All,

 

You can find the latest documentation here:

http://developers.meraki.com/docs ->  redirects to -> https://api.meraki.com/api_docs

 

I recommend using the Postman collection:

http://developers.meraki.com/postman

 

Sometimes the Postman takes a day to get updated but we try out best to keep it up to date!

 

Cheers

Colin Lowenberg
Take the Meraki Challenge
solutions.meraki.com/challenge

The VLANs section of the API calls are for the MX appliance. 

You can see in the call that it needs the applianceIp as a parameter and the query is a networkId

 

I do believe the documentation can be more clear on this. I have updated the Postman to be more obvious.

Screen Shot 2017-11-17 at 10.20.09 AM.png

Screen Shot 2017-11-17 at 10.31.59 AM.png

 

Hi,

I see the same problem; POST request is just sitting there and not going anywhere. GET works fine. I have tried with cURL(I have removed KEY and NETWORK id):

curl --request POST \
--url 'https://dashboard.meraki.com/api/v0/networks/<network>/vlans' \
--header 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
--header 'x-cisco-meraki-api-key: <key>' \
--form id=856
--form name=Test2 \
--form applianceIp=172.17.255.1 \
--form subnet=172.17.255.0/24

and this works fine. I also imported this cURL stuff into Postman; still no luck :-/; POST still . I guess I am doing something wrong, but lack the knowledge to find the error. If anybody could point me in the right direction, it would be much appreciated :-).

I think I need to configure something in Postman; some environment variables maybe, but I am not sure.

There is also missing the 'id' key in the 'add vlan' Postman collection from Meraki ;-). Remember to add that.

Hi,

 

I think I know what's going on.

 

First, ensure that you have VLANs "enabled" for the MX appliance. You have to do this in the Dashboard first. Then, all API calls should work.

 

Second, using dashboard.meraki.com or api.meraki.com, involves redirects to your organization's shard. This is the physical server where your account resides. You can see this in your dashboard URL (i.e. https://n143.meraki.com/~). Use the n### as the "Shard" number in your calls. I have updated Postman to use the shard number as a variable. I have also added the VLAN ID as a parameter for the post call.

 

Screen Shot 2017-11-21 at 3.12.35 PM.png

Hi,

Thank you for your reply and for the update 🙂

I managed to get it to work, but not using the form-data; using the raw in JSON format, as you do 😉

This 'shard' ID, will that always be the same for the organization/network I am trying to configure?

Is there some way that I can see it, using Postman, like I can see (GET) organizations/network ID's using Postman?

Again, due to my lack of knowledge; can I POST (Again using Postman) multiple VLAN in the same call? E.g. I have 25+ VLAN I need to deploy. It is a hassle to do it via the dashboard, but if could do it via Postman (Like I can in Putty) it would help a lot 🙂

Hey Kruse

 

did you get an update on this one? I am dying, trying to find a solution to add multiple VLANs in a single call.

 

cheers!

Hey Denis,

 

Lot of water under the bridge since then :-D. I don't remember exactly what I did, and I have deleted (By accident) the old script. But from what I can remember, I managed to get the Python code to read a comma separated Excel sheet, and add the VLANs one by one using loops. It was not fast, but compared to doing it via the dashboard, it was blazing fast 😄 😄

 

I have not seen any being able to creating multiple VLANs in one go, even on the same device. Maybe it can be done, but I don't see how, actually, as there are no 'bulk' VLAN creation in the API, as far as I know.

 

BTW: I will do it in another way today, as back then I was using JSON to contact the API. Today I have installed a Meraki library, and calls that when I what to use the Meraki API. Much easier, and I do not have to keep track when Meraki updates their API. I am using this right now, but there are others:

 

https://github.com/meraki/dashboard-api-python

 

I have been looking at this: https://github.com/meraki/meraki-python-sdk, which have a build in function allowing it not to flood the API, and thus avoid your script from failing if you get to busy; i.e. making to many calls per sec. From the tests my colleague have made, it is also a little bit faster to use again maybe because it is not flooding the API.

 

I was creating a lot of VLANs on a MX, and I must warn you: When you reach a certain number of VLANs on the MX, the dashboard and the browser becomes very slow; i.e. very long response times. I don't know what exactly is going on, but I think it is because the browser tries to load all the information at once, and that takes time. Mind you I created more than 300 VLAN interfaces on the MX, and maybe you will create less so you will not have that problem. It is running fine, with DHCP and all; it is just the webpage that loads slowly.

 

Br

Kruse

 

I have a python script that adds vlans with user input.  Basically we use the same vlans across locations so it lets you add the IPs for those.  Will probably need some adjustments but it could be a good start.  Unsure of link rules so i can message you my reddit post if you would like.

Hey,

 

Sorry for the long reply, but are on vacation right now, and I do not login that frequently

 

No problem. Link away :-).

 

Just so I understand: You use the same VLAN throughout the network, but lets users (Only you?) add the VLAN based on the device IP address?

 

-kruse

Thanks, man! I already saw this one a couple of days ago. Will try it out some time. What I've been doing: Building a script for the basic setup of a network. The script reads a CSV which contains the information about VLANs and DHCP settings. My "problem" here is, that it takes fairly long to run (for about 15 VLANs) because it will run one call for each VLAN. But it looks like it's not possible to combine all of the VLANs into one call... Your script looks fairly different then mine! Maybe it will optimize it a bit...I am pretty new to programming so my code looks like hell, I guess.

Regarding updating multiple VLANs in one call; 

 

You might want to checkout Action Batches, which have recently been added to the API. They are designed to combine multiple operations into a single request. This is good for adding VLANs, updating switch ports, managing policies, etc.
https://developer.cisco.com/meraki/api/#/rest/guides/action-batches

 

 

Get notified when there are additional replies to this discussion.