A Python script using the requests library must set the hostname on an IOS XE router with RESTCONF enabled. The YANG node lives at Cisco-IOS-XE-native:native/hostname, the write has to create the value when it is missing and replace it when it is present, and the team standard requires RFC 8040 yang-data media types on both the request and the response. Which RESTCONF request writes the hostname correctly?
Select an answer to reveal the explanation.
Short Explanation
RESTCONF is picky about where you write and how you label the payload. A PUT to the exact node is the create-or-replace hammer that fits this job. Add the yang-data media types and the router knows exactly what language you're speaking.
Full Explanation
RFC 8040 exposes configuration under the /restconf/data root, and a PUT addressed to a specific data resource creates that node when it is absent and replaces it when it is present, which matches the create-or-replace intent exactly. The Cisco-IOS-XE-native:native/hostname path names the module, container, and leaf, and both request and response use application/yang-data+json so the router and any middlebox recognize the encoding; in requests that means building the header dict once and reusing it on every write. The /restconf/config prefix appeared in earlier RESTCONF drafts but is not the data-resource root defined by RFC 8040, POST creates a child beneath the target resource rather than writing the hostname leaf itself, and plain application/json skips the media type the team standard requires. Exam caveat: sibling nodes under the native container stay untouched only because the PUT targets the hostname node rather than the container. Practical check: send the call with curl and an Accept header of application/yang-data+json, then GET the same URL to read the value back.