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: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