nerdexam
Cisco

350-901 · Question #26

Complete the Python script by dragging the correct code snippets from the left (Answer Area) into the placeholders <item X> on the right. The script imports requests, defines a URL and headers, and ha

Sign in or unlock 350-901 to reveal the answer and full explanation for question #26. The question stem and answer options stay visible for context.

Understanding and Using APIs

Question

Complete the Python script by dragging the correct code snippets from the left (Answer Area) into the placeholders <item X> on the right. The script imports requests, defines a URL and headers, and handles HTTP responses. Exhibit:
import requests
url = "https://api.ciscospark.com/v1/rooms"
bearer = "BEARER_TOKEN_HERE"
headers = {"content-type": "application/json", "Authorization": "Bearer " + bearer}
<item 1>:
 response = requests.get(url, headers=headers, verify=False)
 <item 2>
 <item 3>:
 if requests.exceptions.HTTPError as err:
 if response.status_code == <item 4>:
 print("Check Bearer Token")
 elif response.status_code == <item 5>:
 print("Check API Endpoint url")
 elif response.status_code == 500:
 print("Server Error, Try again later")
 else:
 print("HTTP Error") + str(err)
Available options for dragging (from the Answer Area on page 1): 401, 404, try, except, raise_for_status().

Exhibit

350-901 question #26 exhibit

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

#Python requests library#HTTP Error Handling#REST API#HTTP Status Codes
Full 350-901 Practice