A Python automation script must update the hostname of a Cisco network device through a REST API.
The API documentation specifies:
Endpoint: /api/v1/devices/{id}
Method: PUT
Authentication: API key sent in the X-API-Key header
Request body must be JSON: {"hostname": "R1-CORE"}
A successful update returns HTTP 200.
The API rejects requests that exceed the device's current configuration version. In that case, it returns HTTP 409.
The script retrieves the device information first, modifies the hostname, and then sends the update. The update fails with:
HTTP/1.1 409 Conflict
Content-Type: application/json
{
"error": "configuration version conflict",
"current_version": 12,
"submitted_version": 11
}
Which change should the developer make to correctly handle this situation?
Correct answer: Retrieve the latest device representation, obtain the current configuration version, update the hostname, and submit the request using the latest version.
Answer explanation:
HTTP 409 Conflict indicates that the request conflicts with the current state of the target resource. Here, the API explicitly tells the client that it submitted configuration version 11, while the current version is 12.
The correct automation workflow is therefore:
GET latest resource → obtain version 12 → modify hostname → PUT updated representation → handle successful response
The other options confuse HTTP methods, authentication, content types, or transient server errors. Cisco's current objectives specifically include constructing REST API requests, interpreting HTTP response codes, troubleshooting using the response/request/API documentation, using API authentication, and calling REST APIs with Python's requests library.
Correct answer: Retrieve the latest device representation, obtain the current configuration version, update the hostname, and submit the request using the latest version.
Answer explanation:
HTTP 409 Conflict indicates that the request conflicts with the current state of the target resource. Here, the API explicitly tells the client that it submitted configuration version 11, while the current version is 12.
The correct automation workflow is therefore:
GET latest resource → obtain version 12 → modify hostname → PUT updated representation → handle successful response
The other options confuse HTTP methods, authentication, content types, or transient server errors. Cisco's current objectives specifically include constructing REST API requests, interpreting HTTP response codes, troubleshooting using the response/request/API documentation, using API authentication, and calling REST APIs with Python's requests library.
Correct answer: Retrieve the latest device representation, obtain the current configuration version, update the hostname, and submit the request using the latest version.
Answer explanation:
HTTP 409 Conflict indicates that the request conflicts with the current state of the target resource. Here, the API explicitly tells the client that it submitted configuration version 11, while the current version is 12.
The correct automation workflow is therefore:
GET latest resource → obtain version 12 → modify hostname → PUT updated representation → handle successful response
The other options confuse HTTP methods, authentication, content types, or transient server errors. Cisco's current objectives specifically include constructing REST API requests, interpreting HTTP response codes, troubleshooting using the response/request/API documentation, using API authentication, and calling REST APIs with Python's requests library.