A Python script using the requests library applies interface settings to an IOS XE router over RESTCONF. One run answers 409 Conflict with a JSON body, while a typo in the payload answers 400. How should the script interpret a 409 response and the error body that arrives with it?
Select an answer to reveal the explanation.
Short Explanation
A 409 in RESTCONF means the edit conflicted with the datastore, not that your session died. The error body can include fields such as error-tag, error-path, and error-message to help identify the reason and choose a response. It's like a refusal slip that tells you which package failed.
Full Explanation
RFC 8040 defines RESTCONF error replies as structured JSON. A 409 indicates a conflict, and the accompanying ietf-restconf:errors object contains error details such as error-tag and may include error-path and error-message. These details help your script choose whether to retry or report the conflict instead of guessing from the status code alone. Logging the reply as plain text fails to use the machine-readable detail the protocol provides. Blindly retrying every 409 treats every conflict as transient, when a conflict can also be one that will not clear on its own. Assuming the target already exists and marking the change applied hides failures, because the status code does not mean that anything was written. Vendors may also add their own fields beside the standard ones.