Courseiva
Automation →hardMultiple Choice

CCNP Automation Practice Question

A network engineer is using a Python script with the 'requests' library to interact with a Cisco IOS XE device via RESTCONF. The script sends a GET request to the URI 'https://192.168.1.1/restconf/data/ietf-interfaces:interfaces/interface=GigabitEthernet1' but receives a 401 Unauthorized error. The engineer has verified that the RESTCONF service is enabled and the URI is correct. What is the most likely cause of the error?

⚠ Common exam trap

The trap here is assuming that a missing Accept header or incorrect URI causes a 401 error; in reality, 401 is solely about authentication, while other issues yield different status codes.

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 device requires authentication, and the script did not provide valid credentials.

The 401 Unauthorized status code specifically means that the request lacks valid authentication credentials. RESTCONF on Cisco IOS XE requires authentication, and the Python script must include a valid username and password, typically using HTTP Basic Auth. Without it, the device rejects the request. The other options would produce different error codes, such as 406 for missing Accept header or 404 for incorrect URI.

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 RESTCONF request must include an Accept header specifying 'application/yang-data+json'.

    Why it's wrong here

    While the Accept header is important for content negotiation, a missing or incorrect Accept header would typically result in a 406 Not Acceptable error, not 401 Unauthorized. The 401 status code specifically indicates an authentication failure. The engineer should focus on credentials rather than headers, as the device is rejecting the request due to lack of valid authentication.

  • ✗

    The RESTCONF URI is incorrect because it should use 'config' instead of 'data'.

    Why it's wrong here

    In RESTCONF, the URI to access configuration data uses '/restconf/data', not '/restconf/config'. The '/restconf/config' path is used in NETCONF, but RESTCONF uses '/restconf/data' for both configuration and state data. Therefore, the URI is correct. The 401 error is unrelated to the URI structure, as an incorrect URI would return 404 Not Found.

  • ✓

    The device requires authentication, and the script did not provide valid credentials.

    Why this is correct

    A 401 Unauthorized response indicates that the request lacks valid authentication credentials. RESTCONF on Cisco IOS XE requires authentication, typically via HTTP Basic Authentication or token-based methods. If the Python script did not include the 'auth' parameter with a valid username and password, or if the credentials are incorrect, the device will return 401. The engineer must configure the script to send proper authentication headers.

  • ✗

    The device's HTTP server is not enabled, so it is rejecting the connection.

    Why it's wrong here

    If the HTTP server were not enabled, the connection would be refused entirely, resulting in a connection error rather than an HTTP 401 response. A 401 implies that the HTTP server is running and reachable, but the request lacks authentication. The engineer already verified that RESTCONF is enabled, which includes the HTTP server, so this is not the cause.

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 →

How Courseiva writes practice questions · Editorial policy

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.