cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
453
Views
1
Helpful
1
Replies

DNAC API trying to retrieve all devices except "unified ap"

ab23
Level 1
Level 1

I'm trying to get a list of all my devices in DNAC except for access points. I'm not sure how to correctly go about that though. I can't put ?family!= or ?family#. How can I get everything that isn't an access point? 

Here's my python

 
BASE_URL = 'https://server.com'
DEVICES_URL = '/dna/intent/api/v1/network-device'
headers = {'X-Auth-Token' : token, 'Content-Type': 'application/json'}
 
response = requests.get(BASE_URL + DEVICES_URL +"?family=Switches and Hubs", headers=headers)
print(response.json())
1 Reply 1

ab23
Level 1
Level 1

I think I have what I want. 

 

dev_fam = ['Switches and Hubs', 'Storage Networking', 'Security and VPN', 'Wireless Controller', 'Third Party Device']
for x in dev_fam:
    query_string_params = {'family': x}
    response = requests.get(BASE_URL + DEVICES_URL, headers=headers, params=query_string_params)
      for item in response.json()['response']:
       print(item['id'], item['hostname'], item['managementIpAddress'], item['macAddress'], item['platformId'])