cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1318
Views
2
Helpful
8
Replies

Cisco DNAC API: get VLANID from OLD / DISCONNECTED clients

Dominic Stalder
Level 1
Level 1

Hi guys

I am writing a script, which collects data from Cisco Spaces ("Visits reports") and enriches them with information from Cisco DNAC via API.

Most of the time, the MAC addresses from Cisco Spaces can be found via API and "/dna/intent/api/v1/client-detail?macAddress=8c:55:4a:db:45:11", especially the detail > vlanID information is of interest for us

For certain MAC addresses, Cisco DNAC API does not return a VLAN ID:

{
"detail": {},
"connectionInfo": {
"errorCode": 1005,
"message": "Not found",
"detail": "Not found"
},
 
But at the same time, I can search for the respective MAC address directly on Cisco DNAC and I can find the last VLAN ID there:
DominicStalder_0-1691157609402.png

How can I access this kind of information from Cisco DNAC API?

Thanks in advance and best regards

Dominic

1 Accepted Solution

Accepted Solutions

Okay, last resort: Use the internal API. You can use the same login mechanism (and X-Auth-Token) as with the normal API and the following API endpoint + payload:

Method+URL: POST https://{{DNAC}}/api/assurance/v1/host/client/detail
Payload:

{
    "filters": {
        "macAddress": "8c:55:4a:db:45:11"}
}

 

View solution in original post

8 Replies 8

Marcel Zehnder
Spotlight
Spotlight

Hi Dominic, can you confirm, you just use the "macAddress" parameter in your query and don't use the "timestamp" param in your query?

Hi Marcel

I can confirm, I used both options:

First: only with the macAddress param

https://x.x.x.x/dna/intent/api/v1/client-detail?macAddress=8c:55:4a:db:45:11

Second: added the timestamp in epoch milliseconds as well:

https://x.x.x.x/dna/intent/api/v1/client-detail?macAddress=8c:55:4a:db:45:11&timestamp=1689058800000

Regards

Dominic

I'm asking because I get that 1005-error when querying a mac and providing in addition a wrong timestamp (for example for a time, when the client was not yet connected). But this, seems not be the issue in your case.

By debugging it looks like DNAC-UI using internal API calls to collect the corresponding client-information, that might explain why there are differences between the UI and the official API.

Can you try to query the MAC via GET /dna/intent/api/v1/client-enrichment-details you need to provide the parameters via the HEADER (not via query params):
entity_type: mac_address
entity_value: 8c:55:4a:db:45:11

Hi Marcel

I'm asking because I get that 1005-error when querying a mac and providing in addition a wrong timestamp (for example for a time, when the client was not yet connected). But this, seems not be the issue in your case.

I do get the error (errorCode = 1005), when using the query without the timestamp param and even when using a correct timestamp param (I do know, when the client should have been online based on the Cisco Spaces information).

> Can you try to query the MAC via GET /dna/intent/api/v1/client-enrichment-details you need to provide the parameters via the HEADER (not via query params)

Thanks for this hint, I will try it later and will post the results back in this post.

Regards

Dominic

Hi Marcel

just tried the /dna/intent/api/v1/client-enrichment-details call and specified the params in the header. I get some client information there, but unfortunately the vlanId and hostIpV4 attributes are null as well.

But anyhow, thanks for the hint with this additional API call.

Best regards

Dominic

Okay, last resort: Use the internal API. You can use the same login mechanism (and X-Auth-Token) as with the normal API and the following API endpoint + payload:

Method+URL: POST https://{{DNAC}}/api/assurance/v1/host/client/detail
Payload:

{
    "filters": {
        "macAddress": "8c:55:4a:db:45:11"}
}

 

Thanks a lot Marcel, this works perfect as a (second) alternative:

First way: official API (https://{dnac}/dna/intent/api/v1/client-detail) with mac address as param and getting vlanId

1. Alternative way: official API (https://{dnac}/dna/intent/api/v1/client-detail) with mac address as param and getting hostIPv4 (get VLAN ID based on IP subnet)

2. Alternative way: your option above

Thanks a lot for your kind effort!

Best regards

Dominic

 

Marcel Zehnder
Spotlight
Spotlight

Hi Dominic, I'm glad I could help.