Cisco
350-901 · Question #40
Refer to the exhibit. This snippet of a script has recently started exiting abnormally with an exception stating "Unexpected HTTP Response code: 429". response = requests.get(url) if response.status_c
Sign in or unlock 350-901 to reveal the answer and full explanation for question #40. The question stem and answer options stay visible for context.
Understanding and Using APIs
Question
Refer to the exhibit. This snippet of a script has recently started exiting abnormally with an exception stating "Unexpected HTTP Response code: 429".
response = requests.get(url)
if response.status_code != 200:
error_message = "Unexpected HTTP Response code: {}".format(response.status_code)
raise Exception(error_message)
data = response.json()
Which solution handles rate limiting by the remote API?
Exhibit
Options
- Aresponse = requests.get(url) if response.status_code == 429: backoff_seconds = int(response.headers['Retry-After']) sleep(backoff_seconds) elif response.status_code != 200: error_message = "Unexpected HTTP Response code: {}".format(response.status_code) raise Exception(error_message) data = response.json()
- Bresponse = requests.get(url) if response.status_code != 200 and response.status_code != 429: error_message = "Unexpected HTTP Response code: {}".format(response.status_code) raise Exception(error_message) data = response.json()
- Cresponse = requests.get(url) if response.status_code != 200 and response.status_code != 429: backoff_seconds = int(response.headers['Retry-After']) sleep(backoff_seconds) error_message = "Unexpected HTTP Response code: {}".format(response.status_code) raise Exception(error_message) data = response.json()
- Dresponse = requests.get(url) if response.status_code == 429: backoff_seconds = int(response.headers['Retry-After']) sleep(backoff_seconds) response = requests.get(url) elif response.status_code != 200: error_message = "Unexpected HTTP Response code: {}".format(response.status_code) raise Exception(error_message) data = response.json()
Unlock 350-901 to see the answer
You've previewed enough free 350-901 questions. Unlock 350-901 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.
Topics
#API Rate Limiting#HTTP Status 429#Retry Mechanism#Python Requests
