12-01-2022 04:08 PM
Hello Community,
I apologize for all the questions but learning the DNAC ropes and hitting a wall with assign-device-to API operation. I followed the link here and everything works except for the assignment. I get the error below:
>>> response = add_devices_site(headers, building_id, site_devices)
>>> print(response)
{'site': 'Type parameter not available in the input json', 'status': 'False'}
Here are the values being passed to the function:
>>> print(headers)
{'X-Auth-Token': 'xxxxxx', 'Content-Type': 'application/json', '__runsync': 'true', '__runsynctimeout': '30'}
>>> print(building_id)
c942c276-f5be-4520-baa3-894fe47c75a7
>>> print(site_devices)
{'device': [{'ip': '10.x.x.150'}]}
# Add devices to site
def add_devices_site(headers, site_id, devices):
headers['__runsync'] = 'true'
headers['__runsynctimeout'] = '30'
response = requests.post(BASE_URL + SITE_DEVICE_URL.format(site_id=site_id),
headers=headers, json=devices,
verify=False)
return response.json()
I reviewed the API call sites-assign-devices-to-site but don't see the error. Any help preventing me from continuing to smash my head against my keyboard would be greatly appreciated. I really need to get this to work to finalize an important import.
Thanks in advance.
-E
Solved! Go to Solution.
12-02-2022 04:25 PM
I was able to resolve my own issue after much frustration. Issue was a typo. A couple of useful tips that I will share from this painful learning experience:
I am going to end this post with a motivational quote and off to have a much deserved beer.
“The beautiful thing about learning is that nobody can take it away from you.” ― B.B. King
12-02-2022 08:07 AM
Spend most of my night trying to figure this out and still stuck. I did find that there was a change in API 2.3.3 from 2.2.2. The API call differs:
2.3.3 = /dna/intent/api/v1/assign-device-to-site/{siteId}/device
2.2.2 = /dna/system/api/v1/site/{siteId}/device
Unfortunately updating the code still yields the same results and it barfs the same message.
{'site': 'Site name is missing in input json {"device":[{"ip":"10.x.x.150"}]}', 'status': 'False'}
Is there a sandbox running 2.3.3 or 2.3.4 that I can test with? Does anyone know what the error is referring to when stating the 'site' name is missing in the input json?
Thanks in advance.
12-02-2022 04:25 PM
I was able to resolve my own issue after much frustration. Issue was a typo. A couple of useful tips that I will share from this painful learning experience:
I am going to end this post with a motivational quote and off to have a much deserved beer.
“The beautiful thing about learning is that nobody can take it away from you.” ― B.B. King
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide