Hello,
I have been plunged head first into API stuff having not done programming before : /
I have a decent idea of how it all works but I need to rapidly learn programming 😛
For example, right now I am trying to write a call that will Aggregate 10 pairs of switch ports between two switches (for example aggregate port 48 on switch 1 with port 48 on switch 2).
I found the basic script in the library which looks great, but I assume there is a way to write it to do a range (eg 38 - 48) rather than having to write the same thing out 10 times. Trouble is I'm not sure what language I need to learn for Postman.
I know Python is the most common language for writing scripts but is that what postman uses? Can I just type python into the body field and away I go or does it use something else?
Here is a link about scripting in Postman. The great thing about APIs though is you can really write a script in any language you want. I've written some in Powershell or in CFML (Adobe Coldfusion). Python is a great language to learn too.
Thanks! - Annoyingly it looks like Im going to have to use Python or something if I want to do anything more than basic API calls?
I wanted to stay with postman because it has a really easy interface for collaborating with other team members - sharing scripts in a central repository etc but I guess Im going to have to figure out how to do that with some other Python client : /
Assume you will use this https://developer.cisco.com/meraki/api-v1/#!create-network-switch-link-aggregation to create an aggregate link.
From the documentation...
You need to issue this call for each aggregated link you want to create.
An aggregated link can have from 2 to 8 ports
The ports must each be specified in the call as serial number + port number, there is no option to specify a range.
To create ten links, you could create a 'for' loop to issue the ten calls, incrementing the port number each time, like...
ser1 = serialnumberofswitch1
ser2 = serialnumberof switch2
for port_num from 1 to 10
create_link(ser1, ser2, port_num)
...this is illustrative, not code in any particular language
thanks!
I was just about to reply with some sudo code of what I need to figure out how to code, more or less the same as yours I think, although I was using a variable counter for port number. I dont think I can do this in postman? I'll have to get Python installed and working 🙂
Var1 = Serial 1
Var2 = Serial 2
Var3 = 38 #portId
For Loop until var3=48
{
"switchPorts": [
{
"serial": "var1",
"portId": "var3"
},
{
"serial": "Var2",
"portId": "Var3"
}
],
}
Set "var3"+1
Not sure about Postman as I use Python, once you get started it's pretty straightforward, there're a lot of sites with Python examples/tutorials.
Install the latest full release for your platform, probably 3.10 at the moment. Once you've got it set up, install the Meraki Python package (pip3 install meraki).
On linux/Mac I use always use pyenv to install Python, if you are using Windows there also a version (I haven't tried it though).
I'd recommend you install using pyenv it as it can simplify using/managing your Python environment. See https://pypi.org/project/pyenv-win/ for instructions for Windows if that's what you will use.
Iv actually found something called replit that might work for python collaboration, however I am having an issue installing the meraki module via pip but thats a separate issue.
Thanks!