CCNP Automation Practice Question
A network engineer is using the Python requests library to interact with a Cisco IOS XE device's RESTCONF API. The engineer wants to retrieve the configured hostname. Which HTTP method and URI should be used?
⚠ Common exam trap
Candidates often confuse the HTTP methods for reading versus writing, and mixing up YANG models for different data.
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
✓
GET https://<device-ip>/restconf/data/Cisco-IOS-XE-native:native/hostname
To retrieve the hostname via RESTCONF, the engineer must use the GET method with the correct URI that points to the hostname leaf in the Cisco IOS XE native YANG model. The URI structure includes the module name (Cisco-IOS-XE-native), the container (native), and the leaf (hostname). This is a straightforward read operation.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
PUT https://<device-ip>/restconf/data/Cisco-IOS-XE-native:native/hostname
Why it's wrong here
PUT is used to replace a resource, not to read it. Using PUT would attempt to set the hostname, not retrieve it. Additionally, a PUT request requires a body with the new value. This is not the correct method for reading data.
- ✗
POST https://<device-ip>/restconf/data/Cisco-IOS-XE-native:native/hostname
Why it's wrong here
POST is used to create a new resource or invoke an operation, not to retrieve data. Using POST on this URI would likely result in an error or unintended modification. To read the hostname, the GET method is required. Therefore, this option is incorrect.
- ✓
GET https://<device-ip>/restconf/data/Cisco-IOS-XE-native:native/hostname
Why this is correct
This is the correct RESTCONF URI to retrieve the hostname from the Cisco IOS XE native YANG model. The GET method is used to read data. The URI path follows the YANG model structure, starting with the module name and then the data node. This will return the hostname if configured.
- ✗
GET https://<device-ip>/restconf/data/ietf-interfaces:interfaces/interface=GigabitEthernet1
Why it's wrong here
This URI retrieves information about a specific interface, not the hostname. While it uses the correct HTTP method, the data path is wrong. The hostname is part of the native model, not the ietf-interfaces model. Thus, this would not return the hostname.
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 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 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.