cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
633
Views
0
Helpful
2
Replies

DNAC API assign-device-to-site Failing

evanm
Level 1
Level 1

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

1 Accepted Solution

Accepted Solutions

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:

  • DNAC Platform - Developer Toolkit page on your server is the best starting point. Unfortunately, I wasn't aware of it causing much of the headaches. I used it to test the API call from there after manually adding the required parameters (building ID / device array). It provides a great overview as well of the parameters, schema required and sample examples in various coding languages. It also confirmed the feature worked and that the problem was end user related.
  • Using the web browser's Developer Tools during API calls is great. This allowed me to capture the data being transmitted and review header and payload information.

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

View solution in original post

2 Replies 2

evanm
Level 1
Level 1

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.

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:

  • DNAC Platform - Developer Toolkit page on your server is the best starting point. Unfortunately, I wasn't aware of it causing much of the headaches. I used it to test the API call from there after manually adding the required parameters (building ID / device array). It provides a great overview as well of the parameters, schema required and sample examples in various coding languages. It also confirmed the feature worked and that the problem was end user related.
  • Using the web browser's Developer Tools during API calls is great. This allowed me to capture the data being transmitted and review header and payload information.

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