CCNP Automation Practice Question
A network engineer is building a Python script to retrieve the operational status of all GigabitEthernet interfaces from a Cisco IOS XE device. The script uses the requests library and sends a GET request to the RESTCONF URL https://10.1.1.1/restconf/data/ietf-interfaces:interfaces-state. The device returns HTTP 401 Unauthorized. The engineer has verified that the RESTCONF service is enabled and the URL is correct. Which action should be taken to resolve the issue?
⚠ Common exam trap
The trap here is assuming that a 401 error is caused by an incorrect URL or missing header, rather than recognizing it as a clear indication of missing or invalid authentication credentials.
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
✓
Include HTTP Basic Authentication credentials in the request using the auth parameter of the requests library.
The HTTP 401 Unauthorized response indicates that the RESTCONF request lacked valid authentication. Cisco IOS XE devices require authentication for RESTCONF operations, typically using HTTP Basic Authentication. Adding the appropriate credentials via the requests library's auth parameter will allow the request to proceed. Other changes, such as modifying headers or HTTP methods, do not address the authentication requirement.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Change the HTTP method from GET to POST to retrieve operational data.
Why it's wrong here
RESTCONF uses GET to retrieve data, while POST is used to create new resources. Changing the method would not address the authentication failure and would likely result in a different error, such as 405 Method Not Allowed. The 401 status clearly points to missing authentication, not an incorrect HTTP method.
- ✓
Include HTTP Basic Authentication credentials in the request using the auth parameter of the requests library.
Why this is correct
RESTCONF on Cisco IOS XE requires authentication for all requests. HTTP 401 Unauthorized explicitly means the request lacks valid credentials. Providing a username and password via HTTP Basic Authentication (e.g., requests.get(url, auth=('admin', 'password'))) supplies the necessary authentication, allowing the request to succeed if the credentials are correct and the user has sufficient privileges.
- ✗
Add an Accept header with the value application/yang-data+json to the request.
Why it's wrong here
An Accept header specifies the desired response format, but it does not provide authentication credentials. The 401 Unauthorized status indicates that the request lacks valid authentication, not that the response format is incorrect. Adding this header would still result in a 401 error because the device requires credentials before processing the request.
- ✗
Enable the NETCONF protocol on the device and use it instead of RESTCONF.
Why it's wrong here
While NETCONF can also retrieve operational data, switching protocols does not solve the immediate authentication problem. The RESTCONF request failed due to missing credentials, not because RESTCONF is incapable of retrieving interface state. The engineer would still need to provide authentication for NETCONF. The correct fix is to add authentication to the existing RESTCONF request.
Visual reference
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.