300-435 practice question 4 of 25

The automation engineer must replace device configuration using RESTCONF. How is this configured using the Python library Requests?

Full set: 125 questions
Answer options
A: delete()
B: post()
C: put() Correct answer
D: patch()
Correct Answer:
C. put()
Explanation

In the RESTCONF protocol, the HTTP PUT method is used to completely replace the target data resource. If the resource exists, it is replaced; if it does not exist, it is created. The Python requests library directly maps HTTP methods to its functions. Therefore, to replace a device configuration, an automation engineer would use the requests.put() function to send a PUT request to the appropriate RESTCONF API endpoint with the new configuration in the request body.

Why Incorrect

A. delete(): This method corresponds to the HTTP DELETE verb, which is used to remove a resource, not replace it.
B. post(): This method corresponds to the HTTP POST verb, which is used to create a new data resource within a collection or to invoke an RPC.
D. patch(): This method corresponds to the HTTP PATCH verb, which is used to partially modify or merge data into an existing resource, not replace it entirely. ---

References

1. RFC 8040 - RESTCONF Protocol:

Section 4.5

"Replacing a Resource": "The PUT method is used to replace the target data resource... If the target resource exists

it is replaced. If the target resource does not exist

it is created." This section explicitly defines the role of the PUT method for resource replacement.

Section 4.4

"Creating a Resource": This section details the use of POST for creation.

Section 4.6

"Modifying a Resource": This section details the use of PATCH for partial modification.

Section 4.7

"Deleting a Resource": This section details the use of DELETE for removal.

2. Cisco IOS XE Programmability Configuration Guide

Cisco IOS XE 17.x:

Chapter: "RESTCONF Protocol"

Section: "RESTCONF Requests and Responses": This documentation confirms the standard HTTP method usage for RESTCONF on Cisco devices. It specifies that "To replace the contents of the resource identified by the target URI

use the PUT method."

3. Python Requests Library Official Documentation:

Section: "Quickstart"

Subsection: "Make a Request": The documentation shows the direct mapping of HTTP methods to function calls

stating: r = requests.put('https://httpbin.org/put'

data={'key':'value'}). This confirms put() is the function for an HTTP PUT request.

Scroll to Top