350-901 · Question #40
350-901 Question #40: Real Exam Question with Answer & Explanation
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.
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?
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.