Question 1,847 of 1,420
mediumMultiple ChoiceObjective-mapped
350-401 Practice Question: Uses the Cisco DNA Center REST API to retrieve…
A network engineer uses the Cisco DNA Center REST API to retrieve the list of devices. The API returns the following JSON:
```json
{
"response": [
{
"id": "12345678-1234-1234-1234-123456789abc",
"managementIpAddress": "192.168.1.1",
"hostname": "Router1",
"platformId": "ISR4331",
"role": "ACCESS",
"series": "ISR4300 Series"
}
],
"version": "1.0"
}```
The engineer writes the following Python code to extract the hostname of the first device:
```python
import requests
url = 'https://dna-center.local/dna/intent/api/v1/network-device' headers = {'X-Auth-Token': 'valid_token', 'Accept': 'application/json'} response = requests.get(url, headers=headers, verify=False) data = response.json()
hostname = data['response'][0]['hostname'] print(hostname)
```
What is a potential 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 does not check if the HTTP response status is 200 before parsing JSON, which could lead to errors if the token is invalid.
The code assumes the API call succeeds and the 'response' list is non-empty. If the token is expired or the API returns an error, response.json() may not have the expected structure, causing a KeyError or IndexError. The code lacks error handling for HTTP status codes and empty responses.
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 URL is missing the '/v1' version segment.
Why it's wrong here
The URL includes '/v1'.
- ✓
The code does not check if the HTTP response status is 200 before parsing JSON, which could lead to errors if the token is invalid.
Why this is correct
Without status check, a 401 or 500 error would cause the script to fail unpredictably.
- ✗
The 'Accept' header should be 'application/yang-data+json' for DNA Center.
Why it's wrong here
DNA Center uses standard JSON, not YANG-specific JSON.
- ✗
The 'X-Auth-Token' header is not the correct authentication method; DNA Center uses Basic Auth.
Why it's wrong here
DNA Center uses token-based authentication via X-Auth-Token.
About these practice questions
Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →
Last reviewed: Jun 18, 2026
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.
Question Discussion
Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.
Sign in to join the discussion.