200-901 Infrastructure and Automation Practice Question
A developer is building a Python tool that must retrieve the list of interfaces from a Cisco IOS XE device using the RESTCONF API. The device is reachable at https://10.1.1.1 and supports the ietf-interfaces YANG model. The developer wants to send the request and parse the JSON response. Which Python code snippet correctly performs this operation?
⚠ Common exam trap
Many candidates confuse the Accept header with the Content-Type header; Accept specifies the desired response format, while Content-Type describes the request body.
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
✓
import requests response = requests.get('https://10.1.1.1/restconf/data/ietf-interfaces:interfaces', headers={'Accept': 'application/yang-data+json'}, auth=('admin', 'password')) interfaces = response.json()
RESTCONF uses HTTP methods to manipulate YANG-modeled data. To retrieve data, a GET request is sent to the resource URL, with the Accept header set to application/yang-data+json to request JSON-encoded data. Basic authentication is commonly used. The correct snippet follows these conventions, while the others misuse HTTP methods or headers.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
import requests response = requests.post('https://10.1.1.1/restconf/data/ietf-interfaces:interfaces', headers={'Content-Type': 'application/yang-data+json'}, auth=('admin', 'password')) interfaces = response.json()
Why it's wrong here
Using POST to retrieve data is incorrect because RESTCONF uses GET for read operations. POST is used to create resources. Additionally, the Content-Type header is for the request body, but no body is provided, and the Accept header should be used to specify the desired response format.
- ✗
import requests response = requests.get('https://10.1.1.1/restconf/data/ietf-interfaces:interfaces', headers={'Accept': 'application/json'}, auth=('admin', 'password')) interfaces = response.json()
Why it's wrong here
The Accept header value application/json is not the correct media type for RESTCONF with YANG data. RESTCONF requires application/yang-data+json for JSON-encoded YANG data. Using application/json may cause the server to reject the request or return an error.
- ✓
import requests response = requests.get('https://10.1.1.1/restconf/data/ietf-interfaces:interfaces', headers={'Accept': 'application/yang-data+json'}, auth=('admin', 'password')) interfaces = response.json()
Why this is correct
This snippet uses requests.get with the correct RESTCONF URL path, sets the Accept header to application/yang-data+json, and supplies basic authentication. The response is parsed as JSON. This aligns with RESTCONF conventions for retrieving data from a YANG-modeled interface.
- ✗
import requests response = requests.get('https://10.1.1.1/restconf/data/ietf-interfaces:interfaces', headers={'Content-Type': 'application/yang-data+json'}, auth=('admin', 'password')) interfaces = response.json()
Why it's wrong here
The Content-Type header indicates the media type of the request body, but a GET request has no body. The Accept header should be used to tell the server the desired response format. Without Accept, the server may return XML or an error, and response.json() could fail.
Go deeper
Related to this question
About these practice questions
One of 975 original 200-901 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official Cisco exam blueprint
This 200-901 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 200-901 exam.