Cannot update Switch Ports Configuration.

BobM
Comes here often

Cannot update Switch Ports Configuration.

Hello,

 

I have used 2 different languages( merakiapi.py and c# )  to update the port configuration on a switch ( tags and vlan ) and although the return status is 200, the configuration is not changed. I am sending the following information:

 

PUT v0/devices/{serial-num-of-switch}/switchPorts/1

 

And the data I am sending  is :

 

{
"vlan": 12,
"tags": "test"

}

 

Anything that I am missing to get this working?

 

Thanks in advance.

 

 

 

8 REPLIES 8
BobM
Comes here often

 

Update to issue. I was able to update the port configuration via postman... So wondering why my API apps are not working..

 

HodyCrouch
Building a reputation

Are you certain that you're getting a 200 response?  Some Meraki API calls will respond with a redirect.  Not all libraries default to following redirects and some will even follow the redirect as a GET rather than a PUT or POST.

 

Do you want to share a bit of your python code (make sure to remove API key and any device serial numbers or network ids)?

Adam
Kind of a big deal

Postman just uses the API so possibly a difference in the code/calls you are using?  You can generate code from Postman to compare and verify. 

Adam R MS | CISSP, CISM, VCP, MCITP, CCNP, ITILv3, CMNO
If this was helpful click the Kudo button below
If my reply solved your issue, please mark it as a solution.
BobM
Comes here often

I have discovered the issue the Content-Type was not set to 'application/json'.

 

Still does not explain why I get status 200 when Content-Type is set to 'text/plain'.

 

Thanks.

 

Hi Dear,
Please can you guide me how you have update switch port ? because i'm trying and it's not working

 what i need to do is to shutdown port number 4 of my ms switch

 

when i put the serial number of my switch and the number (port number) 4 and then i add the key enabled: false ( so it shutdown) i get this error: 

 

{
    "errors": [
        "Switch port schedule not found",
        "Storm control is currently not supported in this network",
        "Only one of access policy, MAC whitelist and Sticky whitelist may be specified"
    ]
}
 
Please help !
BobM
Comes here often

Sorry I am using c#  controlling ports on the Meraki switch... So can't help you with specific python issues...

 

One question I do have have you supplied the Organization name to the  Meraki python api?

 

Is this error coming from the SDK method, or from a raw JSON PUT/GET?

Edgar-VO
Building a reputation

Hi there,

 

Here you have a small piece of python code i use to configure a switch .

Script set first port as an uplink and the last port as a Access Point 

The rest of the ports will be Data/Voip

 

 

    my_switch = dashboard.devices.getNetworkDevice(def_network,new_ms_serial)

    my_nr_ports = 48
    my_switch_type = my_switch['model']

    if my_switch_type == "MS120-24LP":
       my_nr_ports = 24
    if my_switch_type == "MS120-24P":
       my_nr_ports = 24
    if my_switch_type == "MS220-24":
        my_nr_ports = 24
    if my_switch_type == "MS220-8":
        my_nr_ports = 8
    if my_switch_type == "MS220-8FP":
        my_nr_ports = 8
    if my_switch_type == "MS22":
        my_nr_ports = 24
        
    for port_nr in range(1,my_nr_ports+1😞
        
        my_switch_port = dashboard.switch_ports.getDeviceSwitchPort(new_ms_serial,str(port_nr))

        my_switch_port = {}

        if port_nr == 1:
            my_switch_port['name'] = "Uplink to MX"
        elif port_nr == my_nr_ports - 1:
            my_switch_port['name'] = "Meraki Access Point"
        else:
            my_switch_port['name'] = "Data/VoIP"
            my_switch_port['type'] = "access"
            my_switch_port['vlan'] = 520
            my_switch_port['voiceVlan'] = 600
            my_switch_port['stpGuard'] = "bpdu guard"

            
        response = dashboard.switch_ports.updateDeviceSwitchPort(new_ms_serial,str(port_nr),**my_switch_port)     
        
 
Get notified when there are additional replies to this discussion.