Cisco
350-901 · Question #34
Refer to the exhibit. Drag and drop the parts of the Python code from the left onto the item numbers on the right that match the missing sections in the exhibit that consumes REST API…
``python def process_all_pages(url): data = [] try: response = requests.get(url) if response.status_code == 200: while response.links['next']['url']: response = requests.get(response.headers.get('Link')) response.raise_for_status() data.append(response.json()) return data…
Using APIs
Question
Refer to the exhibit. Drag and drop the parts of the Python code from the left onto the item numbers on the right that match the missing sections in the exhibit that consumes REST API pagination.```python
def process_all_pages(url):
data = []
try:
response = requests.get(url)
if <item 1> == 200:
while <item 2>:
response = requests.get(<item 3>)
response.raise_for_status()
data.append(response.json())
return data
except Exception as e:
print("Server returned non-200 OK response during pagination")
Exhibit
Explanation
def process_all_pages(url):
data = []
try:
response = requests.get(url)
if response.status_code == 200:
while response.links['next']['url']:
response = requests.get(response.headers.get('Link'))
response.raise_for_status()
data.append(response.json())
return data
except Exception as e:
print("Server returned non-200 OK response during pagination")
Topics
#REST API#Python#Requests Library#Pagination
Community Discussion
No community discussion yet for this question.
