mediumMultiple ChoiceObjective-mapped
CCNP Practice Question: Writes the following Python script to retrieve…
A network engineer writes the following Python script to retrieve the list of devices from Cisco DNA Center using the REST API:
import requests import json
url = "https://dna-center.local/dna/intent/api/v1/network-device" headers = {
"Content-Type": "application/json",
"X-Auth-Token": "valid-token-here"
}response = requests.get(url, headers=headers, verify=False)
if response.status_code == 200:
devices = response.json()
for device in devices["response"]:
print(device["hostname"])else:
print("Error:", response.status_code)What is the issue with this code?
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
The code uses verify=False which is insecure but functional; the main issue is missing pagination handling.
The code does not handle pagination. Cisco DNA Center API returns a maximum of 500 devices by default, and if more exist, the response includes a 'lastIndex' or similar field. The code only processes the first page.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
The code uses verify=False which is insecure but functional; the main issue is missing pagination handling.
Why this is correct
Correct. The API may return multiple pages, but the code only retrieves the first page. It should check for a 'lastIndex' field and loop to fetch all pages.
- ✗
The URL is incorrect; it should be /dna/intent/api/v1/network-device/list.
Why it's wrong here
The URL is correct for listing network devices. The issue is not the URL.
- ✗
The code does not handle authentication properly; it should use Basic Auth.
Why it's wrong here
The X-Auth-Token header is the correct way to authenticate after obtaining a token. Basic Auth is not used for DNA Center REST API.
- ✗
The code fails because it does not import the json module correctly.
Why it's wrong here
The import is correct. The json module is used to parse the response.
About these practice questions
Courseiva writes every 350-401 question from scratch — 1,175 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This 350-401 practice question is part of Courseiva's free Cisco certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 350-401 exam.