QuestionQ94

VerifiedController-Based Network Automation

Question Image

Refer to the exhibit. An engineer must create a Cisco SDWAN vManage script with error handling to raise Python exceptions when the HTTP status code is not ok. Which code snippet must be added to the box in the code to perform this task?

Explanation

raise_for_status() is a method of the requests.Response object, so it must be called on the response returned by the request; the top-level requests module has no such function, and calling it there raises an AttributeError instead of performing the status check. Retrieving the list of device system IPs from the vManage dataservice/system/device/management/systemip endpoint is a read operation, so the request must use the HTTP GET method rather than PUT. response.raise_for_status() then raises requests.exceptions.HTTPError whenever the response carries a 4xx client-error or 5xx server-error status code.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!