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

DNA Center Rest API query syntax: Return specific attributes

briandodds
Level 1
Level 1

I couldnt find anything in the documentation or on the community forum, and struggled to find what I was looking for elsewhere.

I'm building out a monitoring solution for DNA Center using the Rest API and my get queries only need to return a specific field, eg:
For Get-Site I need to only return these 3 attributes in separate queries
Query1: ID - https://dnac_url/dna/intent/api/v1/site?fields=id 
Query2: Name - https://dnac_url/dna/intent/api/v1/site?fields=name 
Query3: Type - https://dnac_url/dna/intent/api/v1/site?fields=type

Other Rest API's I've used have followed this syntax, but it doesnt seem to work on DNA Center. Any help would be much appreciated.

6 Replies 6

pieterh
VIP
VIP

you may need to authenticate first ? Get started with Authentication API - Postman - Cisco DevNet Learning Center

and for the obvious dnac_url  resolves to the actual url/address (VIP) of your DNA's cluster ?

Thanks for the reply. I'm authenticated and get run anything from the examples: For instance:
 https://dnac_url/dna/intent/api/v1/site
Obviously it returns all of the sites. But I dont want all the info, I just need to limit it to Name or ID or Type.

pieterh
VIP
VIP

in the sample template the syntax is:
https:///dna/intent/api/v1/site?name=null&siteId=null&type=null&offset=1&limit=500 

I'd suggest you need https:///dna/intent/api/v1/site?name=null
to only retrieve all names ? (and only names without siteid and type)

briandodds
Level 1
Level 1

Where did you find that sample?
When I try it I get:
{
"message": [
"The input site is not valid or site is not present."
],
"response": []
}

pieterh
VIP
VIP

this comes from : 
Cisco Developer and DevNet: APIs, SDKs, Sandbox, and Community for software developers and network engineers
in left pane search for get site (nb it shows hits for multiple API versions, which may vary)

on the most right pane (configuration) open parameters tab and switch on parameters
you can delete the parameters you do not need to construct the template
then open the template tab and open the curl/python/Nodejs variants as needed

When searching some more, as it is an array, you may need ?fileds=response[name]
pieterh_0-1692786921304.png

 

 

briandodds
Level 1
Level 1

Nope that didnt work, I tried a few variations of response[name] and additionalInfo[name], but nothing worked.