Having Error While Updating Switchport API

SOLVED
Paxson
Conversationalist

Having Error While Updating Switchport API

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
Nash
Kind of a big deal

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
Kind of a big deal

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-a6289...

 

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

BrechtSchamp
Kind of a big deal

Try removing the "accessPolicyNumber": null line.

Nash
Kind of a big deal

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)

 

Nash
Kind of a big deal

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.

Get notified when there are additional replies to this discussion.