12-22-2020 07:57 AM
Hello,
I am trying to change values on an AP via XCC API. According the API doc (https://documentation.extremenetworks.com/Extreme%20Campus%20Controller/v5.16/API/index_rest_gateway...) three values are required:
serialNumber, hardwareType, apName
accordingly, I send the following call:
changes = {"serialNumber" : "2011Y-1111100000","hardwareType" : "AP310i-WR", "apName" : "2011Y-1111100000"", "description" : "ForTesing"}
resp = requests.put(url + "management/v1/aps/2011Y-1111100000"", json=changes, headers=headers, verify=False)
And I receive the following:
{'errors': [{'errorMessage': 'Validation of "ip" failed; ip_addr/gateway/netmask should be set', 'resource': 'AccessPointManager configureAccessPoint.arg1.ip', 'errorCode': 422, 'invalidValue': 'com.extremenetworks.exol.exolcore.restapi.elements.AccessPointElement@571f4c81'}, {'errorMessage': 'Validation of "radios" failed; may not be null', 'resource': 'AccessPointManager configureAccessPoint.arg1.radios', 'errorCode': 422, 'invalidValue': ''}]}
It seems I have add more values to the request. But I can’t see that requirement in the API docu. In addition I don't want to add so many values when I only want to change the description.
Has anyone tried to change individual values successfully?
Solved! Go to Solution.
12-22-2020 08:08 AM
Stephan,
I changed the channels of hundreds AP’s at once with the API very easily.
You must GET the current config and modify the parameter you want to change and then send back the full config adapted.
Here a piece of code I use:
r = requests.get(server + "/management/v1/aps/{0}".format(AP['serialNumber']), headers=headers, verify=False)
body = json.loads(r.content)
if AP['Channel_2.4GHz']: body['radios'][RADIO_MAPPING[body['hardwareType']]['2G']]['reqChannel'] = AP['Channel_2.4GHz'] body['radios'][RADIO_MAPPING[body['hardwareType']]['2G']]['useSmartRf'] = Falser = requests.put(server + "/management/v1/aps/{0}".format(body['serialNumber']), json=body, headers=headers, verify=False)if r.status_code != 200: # This means something went wrong. RESULT += 'error on {}\n'.format(AP)else: RESULT += 'OK for {}\n'.format(AP)print('RESULT\n', RESULT)
Enjoy
Mig
12-22-2020 08:58 AM
Stephan,
Be carefull with some bugs depending on the versions.
Don’t play with the led-status, it could crashes the GUI, the bug seems not present on all releases/platforms and is to be corrected in the next release.
If you change that, go via CLI on the XCC to change back the led-status to recover the GUI.
Mig
12-22-2020 08:54 AM
Hello Mig,
thank you for the update. I have tried reading and writing the complete config.
Much overhead but works.
12-22-2020 08:47 AM
Stephan
I got that info from the support
Mig
12-22-2020 08:19 AM
Hi Mig,
thank you for the fast answer. I suspected that I would have to read and write the whole config, based on the response I got to the request.
But that is not described in the documentation, is it?