12-12-2024 12:25 PM - edited 12-12-2024 12:27 PM
Hi. Does anyone know some way to get IP pools via API? Not the global pool, but the subpools. I have found this in the API documentation:
https://developer.cisco.com/docs/dna-center/get-reserve-ip-subpool/
It supports GET request and requires siteId, but it doesn't work neither with providing site ID in the URL nor in the payload. It always answers:
{"status":false,"message":["Site id should not be empty."]}
I have a python function like this:
def catc_get_ippool():
URI = '/dna/intent/api/v1/reserve-ip-subpool'#/39806d93-bab7-4749-819d-fb92bb0b637d
HEADERS = {
'X-Auth-Token': CATC_AUTH_TOKEN,
'Content-Type': 'application/json',
'Accept': 'application/json'}
DATA="""{'siteId':'39806d93-bab7-4749-819d-fb92bb0b637d'}"""
RESPONE = requests.get(CATC_URL + URI, headers=HEADERS, verify=False, data=DATA)
return RESPONE.text
As mentioned, I tried both the URL method and providing payload, neither works.
Maybe someone knows some other ways to retrieve IP pools information?
Solved! Go to Solution.
12-12-2024 02:44 PM - edited 12-12-2024 03:21 PM
You must supply the siteId as a query parameter. In practice you append the query-string to your URL like this: https://{cat-c}/dna/intent/api/v1/reserve-ip-subpool?siteId={your-site-id}
The following python code is working fine for me on 2.3.7.6:
import requests
url = "https://172.18.97.30/dna/intent/api/v1/reserve-ip-subpool"
params = { "siteId": "aedee3ec-a32e-4fa7-b21d-319636e61c60" }
headers = { 'X-Auth-Token': 'useYourOwnToken' }
response = requests.request("GET", url, headers=headers, params=params, verify=False)
print(response.text)
12-12-2024 02:04 PM
I also tried "/dna/intent/api/v1/ippool" BAPI path which is supposed to work on its own and give back all IP pools as well as "/dna/intent/api/v1/ippool/site/{site_id}" to give back IP Pool for a specific site ID. Neither works with error {'error': 'BAPI not found with technicalName /v1/ippool/ and restMethod GET'}
12-12-2024 02:44 PM - edited 12-12-2024 03:21 PM
You must supply the siteId as a query parameter. In practice you append the query-string to your URL like this: https://{cat-c}/dna/intent/api/v1/reserve-ip-subpool?siteId={your-site-id}
The following python code is working fine for me on 2.3.7.6:
import requests
url = "https://172.18.97.30/dna/intent/api/v1/reserve-ip-subpool"
params = { "siteId": "aedee3ec-a32e-4fa7-b21d-319636e61c60" }
headers = { 'X-Auth-Token': 'useYourOwnToken' }
response = requests.request("GET", url, headers=headers, params=params, verify=False)
print(response.text)
12-12-2024 11:31 PM - edited 12-12-2024 11:38 PM
Indeed, after checking the API docs closely yesterday on reserve-ip-subpool, I found that either siteId or ignoreInheritedGroups parameter is necessary. So it worked for me too with the reserved ones. Thanks for reconfirming.
---------
site id of site from which to retrieve associated reserve pools. Either siteId (per site queries) or ignoreInheritedGroups must be used. They can also be used together.
ignoreInheritedGroups string
Ignores pools inherited from parent site. Either siteId or ignoreInheritedGroups must be passed. They can also be used together.
--------------
But still a puzzle on ippool API.
12-16-2024 01:15 AM
Thanks, it works! Didn't realize it should be supplied as a query parameter.
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