ETExamTower
Q17Controller-Based Network Automation

An engineer needs to onboard a new switch in Cisco Catalyst Center PnP for Day-0 provisioning. The engineer must retrieve an authentication token and POST the device serial number/PID to the PnP import intent endpoint so that it appears in the PnP queue. Not every option is used. <DragDrop items={["Content-Type","post","application/yang-data+json","intent","X-API-Key","x-auth-token","put"]} slots={[{"answer":"x-auth-token","id":"header_token"},{"answer":"Content-Type","id":"header_content_type"},{"answer":"post","id":"method"},{"answer":"intent","id":"path_segment"}]} template={"import requests\n\nrequests.packages.urllib3.disable_warnings()\n\nbase = \"https://198.51.100.10\"\nauth = (\"dnac\", \"Cisco12345\")\n\n# Get token\nt = requests.post(f\"{base}/dna/system/api/v1/auth/token\", auth=auth, verify=False)\nt.raise_for_status()\ntoken = t.json()[\"Token\"]\n\nheaders = {\"{{header_token}}\": token, \"{{header_content_type}}\": \"application/json\"}\npayload = [\n {\"serialNumber\": \"FGL1234ABC\", \"pid\": \"C9300-24T\", \"siteName\": \"Global/Branch1\"}\n]\n\nresp = requests.{{method}}(\n f\"{base}/dna/{{path_segment}}/api/v1/onboarding/pnp-device/import\",\n headers=headers,\n json=payload,\n verify=False,\n)\nresp.raise_for_status()\nprint(\"PnP device imported.\")"} explanation={"Cisco Catalyst Center uses the `x-auth-token` header to send the token returned by its authentication endpoint. Importing a Plug and Play device supplies a JSON serial-number/PID payload by POST to the intent API endpoint `/dna/intent/api/v1/onboarding/pnp-device/import`; therefore the request also uses `Content-Type: application/json`.\n\n**Learn more:** [Device Onboarding — Cisco Catalyst Center API 2.3.7.4](https://developer.cisco.com/docs/dna-center/2-3-7-4/device-onboarding/)"} reuse={false} />

← → navigate · a answer
Discussion · 0
No comments yet. Be the first.