Courseiva
mediumMultiple Choice

CCNP Practice Question: Consider the following Python script using the…

Consider the following Python script using the requests library to interact with a Cisco IOS-XE device via RESTCONF:

```python

import requests
from requests.auth import HTTPBasicAuth

url = 'https://192.168.1.1/restconf/data/Cisco-IOS-XE-native:native/interface/GigabitEthernet=1/0/1' headers = { 'Accept': 'application/yang-data+json', 'Content-Type': 'application/yang-data+json'

}

auth = HTTPBasicAuth('admin', 'cisco')

response = requests.get(url, headers=headers, auth=auth, verify=False)

print(response.json())

```

What is the script attempting to do?

⚠ Common exam trap

Cisco often tests the distinction between HTTP methods in RESTCONF/NETCONF, and the trap here is that candidates may confuse a GET request with a configuration change because they see a URL path that looks like it modifies an interface.

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

✓

It retrieves the configuration of GigabitEthernet1/0/1 in JSON format.

The script uses an HTTP GET request to the RESTCONF API endpoint for GigabitEthernet1/0/1. The GET method is specifically used to retrieve data, and the 'Accept: application/yang-data+json' header tells the server to return the configuration in JSON format. This matches option B exactly.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    It updates the IP address of GigabitEthernet1/0/1.

    Why it's wrong here

    This cannot be correct because the HTTP GET method is reserved for reading data; it must not cause any state change on the server. In RESTCONF, modifying the IP address of an interface would require an HTTP PATCH, PUT, or POST request that sends the desired YANG payload to the target URI. The fact that the URI might contain interface and address elements simply identifies which resource is being retrieved, not that the resource is being mutated. Therefore, a GET request cannot update the IP address.

  • ✓

    It retrieves the configuration of GigabitEthernet1/0/1 in JSON format.

    Why this is correct

    A GET request with an Accept header of application/yang-data+json asks the server to return the YANG configuration data for GigabitEthernet1/0/1 serialized as JSON, per RFC 7951. The server resolves the URI to a specific data node in the running datastore and sends a 200 OK response whose body represents that interface's configuration. This is a read-only operation; the configuration itself remains unchanged. Thus, the correct outcome is a JSON-formatted retrieval of the interface configuration.

  • ✗

    It deletes the interface configuration.

    Why it's wrong here

    Deleting an interface configuration is a destructive mutation that RESTCONF only permits through the HTTP DELETE method, typically with the URI pointing to the interface's data node. A GET request has no request body and is defined by RFC 8040 to be safe and idempotent, meaning it cannot remove a resource. Even though the URI might be identical, the method determines the operation; GET therefore cannot delete the interface configuration.

  • ✗

    It creates a new interface.

    Why it's wrong here

    Creating a new interface instance would require a POST request to the parent collection (e.g., /native/GigabitEthernet) with a JSON payload describing the interface, or a PUT request with a fully specified resource URI. The GET method is only used to retrieve an existing resource and does not have a request body that could convey the new interface definition. Consequently, a GET operation cannot create a new interface; it would simply return the existing data or a 404 if the interface does not exist.

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 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.