300-435 Question 88
Single answerYou are tasked with configuring a Cisco device using the RESTCONF API and the Python requests library. You need to update the device hostname to 'New-Host' using the RESTCONF endpoint /restconf/data/Cisco-IOS-XE-native:native/hostname. Which HTTP method and headers should you use to successfully update the device configuration?
- A
Use the HTTP GET method with the headers 'Accept: application/yang-data+json' and 'Content-Type: application/yang-data+json'
- B
Use the HTTP POST method with the headers 'Accept: application/yang-data+json' and 'Content-Type: application/yang-data+json'
- C
Use the HTTP PUT method with the headers 'Accept: application/yang-data+json' and 'Content-Type: application/yang-data+json'
- D
Use the HTTP DELETE method with no headers
Show answer and explanation
Correct answer: C
Explanation
To update the hostname of a Cisco device using the RESTCONF API and Python requests library, the HTTP PUT method is the appropriate choice. This method is used to replace or update the configuration of a specific resource. Additionally, the 'Accept' and 'Content-Type' headers must be set to 'application/yang-data+json' to specify the use of JSON formatted data compliant with YANG models.
- A. Incorrect.
The HTTP GET method is used to retrieve data from the RESTCONF API, not to update or modify configurations.
- B. Incorrect.
The HTTP POST method is used to create new configuration data but is not typically used for updating an existing configuration like the hostname.
- C. Correct.
The HTTP PUT method is the correct method to update or replace a configuration resource in RESTCONF. The headers 'Accept: application/yang-data+json' and 'Content-Type: application/yang-data+json' ensure the data format is properly handled.
- D. Incorrect.
The HTTP DELETE method is used to remove configuration data, not to update or modify it.