On a Cisco IOS XE device, a RESTCONF hostname leaf may already exist, so the write should replace its value rather than append to it. The device exchanges YANG-encoded JSON on both the request and response. Which HTTP method, target path and header media types should the write use?
Select an answer to reveal the explanation.
Short Explanation
PUT replaces the target resource, and both headers should identify the YANG JSON media type. The path targets the hostname leaf in the IOS XE native configuration model. It’s a handshake where Content-Type says what you are sending and Accept says what you can read.
Full Explanation
RESTCONF maps YANG data nodes onto URLs, and the HTTP verb carries the intent. Writing an existing hostname leaf means replacing its value, which is what PUT does: the request targets /restconf/data/Cisco-IOS-XE-native:native/hostname and carries the new value in the body. Content-Type tells the server how to parse your body, while Accept tells it which YANG media type you can read; application/yang-data+json identifies the JSON encoding. POST creates a child resource, so it is the wrong verb when the goal is to replace an existing value. Sending the change to /restconf/operations targets the RPC and action layer used for invoking an operation, not ordinary data editing. Telling the server the body is XML while sending JSON gives it a mismatched media type and body. Practical check: GET the same URL first with the headers set, send the PUT, then GET again to confirm the hostname value.