03-14-2017 03:24 AM - edited 03-11-2019 12:32 AM
Does anybody know how to use the ERS API in ISE, to export all the switches/wlc's (network devices) ?
I need GET ALL request with Network devices.
In API Documentation there are just two possibilities.
Method GET
Url: https://hostname:9060/ers/config/networkdevice
Method GET
Url: https://hostname:9060/ers/config/networkdevice/{id}
And I want to get link to hole info about all networkdevices (like with the second GET id) in one list
Solved! Go to Solution.
05-08-2020 02:28 PM
When you are getting the list of the devices you are getting their ID, Names and Link.
"id": "9d362e00-fe4d-11e7-87dc-500f80ddff18", "name": "ISE_EST_Local_Host", "link": { "rel": "self", "href": "https://IP:9060/ers/config/networkdevice/9d362e00-fe4d-11e7-87dc-500f80ddff18", "type": "application/json" }
Inside of Link you have Href value with a valid link request to get all the information from the specific device using its ID
e.g. 9d362e00-fe4d-11e7-87dc-500f80ddff18 in my example
Method: GET URI: https://IP:9060/ers/config/networkdevice/{id} HTTP 'Content-Type' Header: application/xml | application/json HTTP 'Accept' Header: application/xml | application/json
Make sure you specify Accept and Content-type in the new requests, cause they are mandatory and this is what your error message is about.
03-15-2017 07:43 AM
In ISE REST API there is a method called GET-ALL for network devices
https://hostname:9060/ers/sdk#Get-All
Will it work for you?
Thanks
03-26-2019 02:26 PM
If you have less than 100 devices total you could use following link to retrieve all of them
GET /ers/config/networkdevice?size=100
Max resources per page cannot be more then 100 resources. You need to use paging to retrieve all resources.
This is a little snippet from my code to get all records if you have more then 100...
def get_device_list(s): """ Return list of the Network Devices Maximum is 100 devices per page ?size=100 Go through the pages &page = 1 """ url = "https://" + ISE_SERVER + ":9060/ers/config/networkdevice?size=100&page=" url = url + "1" resp= requests.request("GET", url, data=payload, headers=headers, params=querystring) device_list = [] if resp.status_code == 200: result = resp.json()['SearchResult'] total = result['total'] pages = total / 100 + 1 for page in range (1, int(pages + 1)): resp= requests.request("GET", url + str(page), data=payload, headers=headers, params=querystring) if resp.ok: result = resp.json()['SearchResult']['resources'] for item in result: device = {} device['id'] = item['id'] device['name'] = item['name'] """ Not all devices has description field """ # device['description'] = item['description'] device['link'] = item['link']['href'] device_list.append(device) return device_list
05-08-2020 09:21 AM - edited 05-08-2020 09:43 AM
This is great, thanks for sharing.
Is there anyway, you can share more code so I can test this function out in my IDE? Specifically, the payload, headers and querystring.
Thanks.
resp= requests.request("GET", url, data=payload, headers=headers, params=querystring)
05-08-2020 10:12 AM
You could try with an empty payload and querystring
url = "https://IP_ADRESS:9060/ers/config/networkdevice" payload = "" querystring = "" headers = { 'Accept': "application/json", 'Content-Type': "application/json", 'Authorization': "Basic ZXJzX2FkbWluOnBhc3N3b3JkCg==" }
Where Auth is username and password encoded with Base64
e.g.
echo ZXJzX2FkbWluOnBhc3N3b3JkCg== | base64 -d ers_admin:password
05-08-2020 10:38 AM - edited 05-08-2020 10:40 AM
I got it work and got all resources from ISE. Thanks for the quick response!
One thing though, why can't I see everything in the network device's resource, like parameters and their set values in the RADIUS Authentication Settings, IP, etc. Below is all I got back, only 3 fields per returned resource item.
{ 'id': '7c0138d0-e157-11e9-bedf-005056bf3145',
'link': 'https://<ISE-server-IP>:9060/ers/config/networkdevice/7c0138d0-e157-11e9-bedf-005056bf3145',
'name': 'abc'}
When I clicked on that URL link, I got this error message. Do you or anyone get the same thing? I included the code snippet at the end as well (note, I turned off ssl verification on purpose, to address the ssl handshake issue).
<ns3:ersResponse xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ns3="ers.ise.cisco.com" operation="GET-get-networkdevice">
<link rel="related" href="https://<ISE-server-IP>:9060/ers/config/networkdevice/7c00eab0-e157-11e9-bedf-005056bf3145" type="application/xml"/>
<messages>
<message type="ERROR" code="Resource media type exception">
<title>
Illeagal Request Header: one or more of 'accept' / 'content-type' / 'ers-media-type' headers is not supported.
</title>
</message>
</messages>
</ns3:ersResponse>
payload = ""
querystring = ""
headers = {
'accept': "application/json",
'authorization': " ".join(("Basic", encodedAuth)),
'Content-Type': "application/json",
'cache-control': "no-cache",
}
url = "https://" + ISE_SERVER + ":9060/ers/config/networkdevice?size=100&page="
url = url + "1"
resp= requests.request("GET", url, data=payload, headers=headers, params=querystring, verify=False)
05-08-2020 10:53 AM
05-08-2020 10:56 AM
This is from the SDK page. Maybe, I have to query for those attributes? There is no instruction on how to do that though.
Maybe Cisco experts here can help shred lights on that.
I got the same thing via postman, only 3 fields.
05-08-2020 11:07 AM
I got it work and got all resources from ISE. Thanks for the quick response!
One thing though, why can't I see everything in the network device's resource, like parameters and their set values in the RADIUS Authentication Settings, IP, etc. Below is all I got back, only 3 fields per returned resource item.
{ 'id': '7c0138d0-e157-11e9-bedf-005056bf3145',
'link': 'https://<ISE-server-IP>:9060/ers/config/networkdevice/7c0138d0-e157-11e9-bedf-005056bf3145',
'name': 'abc'}
When I clicked on that URL link, I got this error message. Do you or anyone get the same thing? I included the code snippet at the end as well (note, I turned off ssl verification on purpose, to address the ssl handshake issue). There is a page (my next post) about resource attributes on the SDK page, but no instructions on how to access those attributes.
<ns3:ersResponse xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ns3="ers.ise.cisco.com" operation="GET-get-networkdevice">
<link rel="related" href="https://<ISE-server-IP>:9060/ers/config/networkdevice/7c00eab0-e157-11e9-bedf-005056bf3145" type="application/xml"/>
<messages>
<message type="ERROR" code="Resource media type exception">
<title>
Illeagal Request Header: one or more of 'accept' / 'content-type' / 'ers-media-type' headers is not supported.
</title>
</message>
</messages>
</ns3:ersResponse>
payload = ""
querystring = ""
headers = {
'accept': "application/json",
'authorization': " ".join(("Basic", encodedAuth)),
'Content-Type': "application/json",
'cache-control': "no-cache",
}
url = "https://" + ISE_SERVER + ":9060/ers/config/networkdevice?size=100&page="
url = url + "1"
resp= requests.request("GET", url, data=payload, headers=headers, params=querystring, verify=False)
05-08-2020 02:28 PM
When you are getting the list of the devices you are getting their ID, Names and Link.
"id": "9d362e00-fe4d-11e7-87dc-500f80ddff18", "name": "ISE_EST_Local_Host", "link": { "rel": "self", "href": "https://IP:9060/ers/config/networkdevice/9d362e00-fe4d-11e7-87dc-500f80ddff18", "type": "application/json" }
Inside of Link you have Href value with a valid link request to get all the information from the specific device using its ID
e.g. 9d362e00-fe4d-11e7-87dc-500f80ddff18 in my example
Method: GET URI: https://IP:9060/ers/config/networkdevice/{id} HTTP 'Content-Type' Header: application/xml | application/json HTTP 'Accept' Header: application/xml | application/json
Make sure you specify Accept and Content-type in the new requests, cause they are mandatory and this is what your error message is about.
05-08-2020 02:34 PM
Yes, I realized that and expanded my code and got all the attributes. Thanks again!
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