09-14-2021 05:24 AM
I want to call client details such as username, IP, MAC from DNAC controlled switches via API. I am running Version 1.3.3.9.
I get an auth token by supplying login credentials via Basic Auth. Then i call /api/v1/host to get a list of all endpoints (i know this is deprecated but i could not find a newer alternative...) so far everything works.
Then i use the MAC that is returned from the last API call, in this format: "00:00:2a:01:00:19" and pass it as a JSON Body into /dna/intent/api/v1/client-detail:
But i get back HTTP 200 - "errorMessage" : "MAC Address has an invalid format". Why? I tried every possible format i can think of, removing ":", replacing it with "-", uppercase, lowercase. I dont understand, what is this error? I tried it with the devnet sandbox aswell, same issue.
Solved! Go to Solution.
09-27-2021 09:47 AM
Hi @pescla,
Well, the Version 1.3.3 Docs (https://dnacentersdk.readthedocs.io/en/latest/api/api.html#clients-1-3-3) state the following:
get_client_detail(mac_address, timestamp=None, headers=None, **request_parameters)[source]
Returns detailed Client information retrieved by Mac Address for any given point of time. .
timestamp (basestring, int) – Epoch time(in milliseconds) when the Client health data is required.
mac_address (basestring) – MAC Address of the client.
headers (dict) – Dictionary of HTTP Headers to send with the Request .
**request_parameters – Additional request parameters (provides support for parameters that may be added in the future).
JSON response. Access the object’s properties by using the dot notation or the bracket notation.
TypeError – If the parameter types are incorrect.
MalformedRequest – If the request body created is invalid.
ApiError – If the DNA Center cloud returns an error.
You are converting the MAC address to a string, so that's correct. The error you're getting doesn't exactly match anything they have listed here. Have you tried truncating the leading zeros in the MAC address? I think it would be "::2a:01:00:19", at least that's how we do it with IPv6. Not sure if it's allowed with MACs, actually, but it's worth a try. Another thing to observe is that this MAC begins with a zero, meaning it's Unicast. Is that type of traffic allowed?
09-27-2021 09:47 AM
Hi @pescla,
Well, the Version 1.3.3 Docs (https://dnacentersdk.readthedocs.io/en/latest/api/api.html#clients-1-3-3) state the following:
get_client_detail(mac_address, timestamp=None, headers=None, **request_parameters)[source]
Returns detailed Client information retrieved by Mac Address for any given point of time. .
timestamp (basestring, int) – Epoch time(in milliseconds) when the Client health data is required.
mac_address (basestring) – MAC Address of the client.
headers (dict) – Dictionary of HTTP Headers to send with the Request .
**request_parameters – Additional request parameters (provides support for parameters that may be added in the future).
JSON response. Access the object’s properties by using the dot notation or the bracket notation.
TypeError – If the parameter types are incorrect.
MalformedRequest – If the request body created is invalid.
ApiError – If the DNA Center cloud returns an error.
You are converting the MAC address to a string, so that's correct. The error you're getting doesn't exactly match anything they have listed here. Have you tried truncating the leading zeros in the MAC address? I think it would be "::2a:01:00:19", at least that's how we do it with IPv6. Not sure if it's allowed with MACs, actually, but it's worth a try. Another thing to observe is that this MAC begins with a zero, meaning it's Unicast. Is that type of traffic allowed?
09-27-2021 11:10 PM
Thanks, that must have been it, i could use the API successfully in the 2.2.2.3 Cisco Sandbox and will try in our environment when our new 2.2.x DNAC is ready.
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