cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3748
Views
4
Helpful
5
Replies

Having Error While Updating Switchport API

Paxson
Community Member

I have been trying to update a switch port with the following json file however is keep giving me a error.

{"name": "Test1", "tags": "null", "enabled": true, "poeEnabled": true, "type": "access", "vlan": 10, "voiceVlan": null, "allowedVlans": "all", "isolationEnabled": false, "rstpEnabled": true, "stpGuard": "disabled", "accessPolicyNumber": null, "linkNegotiation": "Auto negotiate", "portScheduleId": null, "udld": "Alert only", "macWhitelist": ["34:56:fe:ce:8e:b0", "34:56:fe:ce:8e:b1"] }


Only one of access policy, MAC whitelist and Sticky whitelist may be specified

MAC whitelist and Sticky whitelist may be specified but there no field of this two field in the data model

Any advise is welcome

1 Accepted Solution

Accepted Solutions

Nash
Level 11
Level 11

Remove all null entries. I just had to do this for a client.

If you want to whack it in Python:

empties = []
for key, value in port.items():
    if value == None:
        empties.append(key)
for item in empties:
    try:
        port.pop(item)
    except:
        print(f"Couldn't pop {item}")
putSwitchport(arg_apikey, arg_serial, port, switchportNum, shard)

View solution in original post

5 Replies 5

BrechtSchamp
Level 11
Level 11

Isn't it called "stickyMacWhitelist" instead of "macWhitelist"?

See in the example in the docs here:

https://documenter.getpostman.com/view/7928889/SVmsVg6K?version=latest#d3edbb74-e6f6-4dc2-99f7-a62897bc4e94

Edit: Both are actually valid options.

Both fieldname have been tested however it still give the same error for us to select one of those 2 access policy

Try removing the "accessPolicyNumber": null line.

Nash
Level 11
Level 11

Remove all null entries. I just had to do this for a client.

If you want to whack it in Python:

empties = []
for key, value in port.items():
    if value == None:
        empties.append(key)
for item in empties:
    try:
        port.pop(item)
    except:
        print(f"Couldn't pop {item}")
putSwitchport(arg_apikey, arg_serial, port, switchportNum, shard)

BTW, after discussing this with @BrechtSchamp I realized I forgot to say - if you need to _set_ a field as null, make sure it's specifically included.

But if it's already null and will remain null, you can remove the key:value pair.