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.
Go deeper
Related to this question
Learn chapter
Network Architecture Fundamentals
Key term
REST API for Network Devices
A REST API for network devices is a set of rules that allows software applications to communicate with routers, switches, and firewalls using standard web methods like GET, POST, PUT, and DELETE over HTTP or HTTPS.
Key term
Cisco DNA Center
A centralized network management and automation platform from Cisco that provides intent-based networking for easier configuration, monitoring, and troubleshooting of Cisco devices.
About these practice questions
This 350-401 question is part of Courseiva's 1,175-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam 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.