Update MS QOS Rules

Solved
webfrank
Getting noticed

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

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

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

 

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

 

webfrank
Getting noticed

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.

PhilipDAth
Kind of a big deal
Kind of a big deal

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

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}")

 

 

Get notified when there are additional replies to this discussion.