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
Solved! Go to solution.
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)
Isn't it called "stickyMacWhitelist" instead of "macWhitelist"?
See in the example in the docs here:
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.
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.