QuestionQ40

Controller-Based Network Automation

An engineer must create a site-level health snapshot from Cisco Catalyst Center for an executive dashboard. The engineer must authenticate and query the Site Health resource by using the token header and a millisecond timestamp query parameter. Drag the code snippets into the boxes to construct the artifact. Not every option is used.

Drag & Drop
import requests, time

base = "https://dnac.example.local"
user, pwd = ("apiuser", "apipass")

# token
t = requests.post(f"{base}/", auth=(user, pwd), verify=False)
t.raise_for_status()
token = t.json()["Token"]

# site-health
ts = int(time.time() * 1000)
headers = {"": token}

r = requests.get(f"{base}/dna/intent/api/v1/?={ts}", headers=headers, verify=False, timeout=15)
r.raise_for_status()
site_data = r.json()
print("Sites reported:", len(site_data.get("response", [])))
Explanation

The Site Health request uses the site-health resource and a timestamp query parameter containing the current epoch time in milliseconds. Authentication obtains a token from the token resource and passes that token in the x-auth-token header; Authorization is not the Catalyst Center token header.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!