Hello TIm,
I also tried Urlenconding the data before sending with no luck. The code I posted is pretty much the same I use to manage the Clearpass API, so I think the code is ok. I could have overlook something though.
string_query={"devices" : [ "34:FC:B9:CE:14:7E"]}
jsonbody_url=urllib.parse.urlencode(string_query)
json_alta_guest_bytes=jsonbody_url.encode("utf-8")
req=urllib.request.Request(line+"/api/ext/inventory.json?action=query&deviceFilter=basicData&addDate=06-16-2017",data=json_alta_guest_bytes,headers={"Cookie" : cookie,
"Content-Type": "application/x-www-form-urlencoded", "charset":"UTF-8","Content-length":len(json_alta_guest_bytes),
"Connection": "Keep-Alive"},method='POST')
In case it helps, I tried with an APi that only accepts json body filters (folder update API)
string_query={"devices" : [{"mac" : "20:4C:03:04:31:80",
"deviceName" : "nombre de prueba",
"folderName": "XXXX"}]}
json_alta_guest=urllib.parse.urlencode(string_query)
datos=json_alta_guest.encode('utf-8')
req=urllib.request.Request(line+"/api/ext/inventory.json?action=update",data=datos,headers={"Cookie" : cookie,
"charset":"UTF-8","Content-length":len(datos),"Host": "activate.arubanetworks.com",
"Connection": "keep-alive","Accept-Encoding":"deflate, br","Origin":"https://activate.arubanetworks.com",
"Referer":"https://activate.arubanetworks.com/registration/","Accept-Language":"es-ES,es;q=0.8"},method='POST')
try:
f=urllib.request.urlopen(req)
and this is the server response:
-----errors': [{'key': 'json', 'errMessage': 'json POST parameter must be supplied for update action.'}]}
Do you have any way to check what's the reason the server returns this error?
I tried with the other version too:
string_query={"devices" : [{"mac" : "20:4C:03:04:31:80",
"deviceName" : "nombre de prueba",
"folderName": "XXXX"}]}
json_alta_guest=json.dumps(string_query)
datos=json_alta_guest.encode('utf-8')
req=urllib.request.Request(line+"/api/ext/inventory.json?action=update",data=datos,headers={"Cookie" : cookie,
"charset":"UTF-8","Content-length":len(datos),"Host": "activate.arubanetworks.com",
"Connection": "keep-alive","Accept-Encoding":"deflate, br","Origin":"https://activate.arubanetworks.com",
"Referer":"https://activate.arubanetworks.com/registration/","Accept-Language":"es-ES,es;q=0.8","Accept":"*/*"},method='POST')
and same server response
Thank you very much