hardMultiple Choice
350-401 Practice Question: Uses the Requests library to query a Cisco IOS-XE…
A network engineer uses the Requests library to query a Cisco IOS-XE device via RESTCONF for interface statistics:
```python
import requests from requests.auth import HTTPBasicAuth
url = 'https://192.168.1.1/restconf/data/Cisco-IOS-XE-interfaces-oper:interfaces/interface=GigabitEthernet1/0/1/statistics' headers = {'Accept': 'application/yang-data+json'} auth = HTTPBasicAuth('admin', 'cisco123') response = requests.get(url, headers=headers, auth=auth, verify=False)
print(response.json())
```
What is the most likely issue with this code?
⚠ Common exam trap
Candidates may overlook the requirement to URL-encode special characters like '/' in RESTCONF URIs and assume the code is correct, leading them to select superficially plausible but incorrect options such as A or C.
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 interface name 'GigabitEthernet1/0/1' in the URL must be URL-encoded as 'GigabitEthernet1%2F0%2F1'.
The code contains an unencoded slash in the interface name 'GigabitEthernet1/0/1', which is a special character in RESTCONF URIs. It must be URL-encoded as 'GigabitEthernet1%2F0%2F1' to be correctly interpreted as a list key value. Therefore, option B correctly identifies the issue. Option A is false because the URL already includes '/restconf/data/'. Option C is incorrect because 'application/yang-data+json' is the proper Accept header for RESTCONF YANG data. Option D is false because GET is the correct HTTP method for data retrieval.
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 '/data' segment; it should be '/restconf/data/...'
Why it's wrong here
The URL actually already contains the '/data' segment if it begins with '/restconf/data/'. RESTCONF mounts YANG datastores under '/restconf/data', so omitting that segment would target the RESTCONF root or operations rather than specific data nodes. The real flaw in the code is not a missing '/data' but an unencoded slash inside the interface-name key, which corrupts the path hierarchy.
- ✓
The interface name 'GigabitEthernet1/0/1' in the URL must be URL-encoded as 'GigabitEthernet1%2F0%2F1'.
Why this is correct
In a RESTCONF URI, each slash delimits a path segment, so an interface name like 'GigabitEthernet1/0/1' must be percent-encoded as 'GigabitEthernet1%2F0%2F1' to remain a single key segment. Without encoding, the server interprets the input as multiple nested path elements (e.g., an 'interface' container with intermediate nodes), causing the request to 404 or target the wrong data. Thus the fix is to URL-encode the interface name before constructing the request.
- ✗
The Accept header should be 'application/json' instead of 'application/yang-data+json'.
Why it's wrong here
The Accept header 'application/yang-data+json' is exactly the RESTCONF media type that tells the server to return YANG-modeled data in JSON, matching the module-defined structure. Changing to 'application/json' would ask for generic JSON, which could cause the server to reject the request or return an unexpected representation. Therefore, this header is not the source of the error.
- ✗
The HTTP method should be POST instead of GET.
Why it's wrong here
The request uses GET because it is retrieving the configuration or state of the specified interface from the datastore. POST in RESTCONF is only for creating a new data resource or invoking an RPC operation, not for reading an existing node. Replacing the method with POST would change the semantics and likely fail or create an unintended resource.
Go deeper
Related to this question
Learn chapter
SDN Controllers and Cisco ACI
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
NETCONF Protocol
NETCONF is a network management protocol that uses a structured data format to configure, retrieve, and modify network devices in a standard, programmatic way.
About these practice questions
Courseiva writes every 350-401 question from scratch — 1,923 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.