10-21-2019 12:26 AM
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.
10-21-2019 06:33 AM
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)
10-21-2019 02:00 AM
Isn't it called "stickyMacWhitelist" instead of "macWhitelist"?
See in the example in the docs here:
Edit: Both are actually valid options.
10-21-2019 02:53 AM
Both fieldname have been tested however it still give the same error for us to select one of those 2 access policy
10-21-2019 04:00 AM
Try removing the "accessPolicyNumber": null line.
10-21-2019 06:33 AM
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)
10-22-2019 06:06 AM
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.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide