cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
4259
Views
2
Helpful
4
Replies

Update MS QOS Rules

Hi,

I'm trying to update a previously GET qosRule using API. If I GET the QOS Rule I have something like this:

{
"id" : "645703596574246393",
"vlan" : null,
"protocol" : "UDP",
"srcPort" : null,
"dstPort" : null,
"dscp" : NumberInt(46)
}

as you can read vlan, srcPort and distort are null because I put "Any" from the Dashboard.

If I try to PUT the same JSON I receive an error because vlan, srcPort and distort should be integer and not 0.

What I'm doing wrong here? I tried to pass "Any" instead of null but the same error occurs.

1 Accepted Solution

Accepted Solutions

ww^
Meraki Community All-Star
Meraki Community All-Star

Looks like you need to specify them, or just leave them out of the script.

"srcPort": 2000,
"srcPortRange": null,
"dstPort": null,
"dstPortRange": "3000-3100",

View solution in original post

4 Replies 4

ww^
Meraki Community All-Star
Meraki Community All-Star

Looks like you need to specify them, or just leave them out of the script.

"srcPort": 2000,
"srcPortRange": null,
"dstPort": null,
"dstPortRange": "3000-3100",

Thanks everybody, I found just few minutes later it was necessary not to specify null fields.

I think this should not be an API behavior as this logic should be inside API and not on caller.

Philip D'Ath
Meraki Community All-Star
Meraki Community All-Star

Untested, but I would do something like:

if row['vlan'] is None:
   del row['vlan']
if row['srcPort'] is None:
   del row['srcPort']
if row['dstPort'] is None:
   del row['dstPort']

Nash
Level 11
Level 11

In addition to Philip's idea, you can also do something like the below. Just modify or add checks as necessary to remove empty or Null returns.

This is copy-pasta from a script I use to update switchports. Script reads in JSON that's a result of GETting the switchport data, then adjusts it so I can later POST the result.

Edited to add: This is Python, because I love snakes.

for port in switchportsList:
    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}")