Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1requests.post(url, json=data) | Aif response.status_code == 201: | |
| 2response.status_code | BSends the dictionary data to the API at url as a JSON request body | |
| 3GET only fetches data from an API, so to send a dictionary to an API you use POST instead | CGives the number the API sent back, such as 201, to show whether the request worked | |
| 4After sending data, check that the API accepted it by testing the status code | DThe dictionary is passed without the json= keyword, so requests does not send it as a JSON body. It should be json=data. | |
| 5requests.get(url, json=data) | Erequests.post(url, json=student) | |
| 6requests.post(url, data) | Frequests.get() is used to fetch data, not send it. To send data as a JSON body, use requests.post(). |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
requests.post(url, json=data) — Sends a Python dictionary to a web API as a JSON request body, unlike GET which only fetches data. Check the response with response.status_code.response = requests.post(url, json=data)response = requests.post(url, json=data)if response.status_code == 201:
print("Saved")info = requests.get(url) # fetch onlydata = {"name": "Ava", "score": 95}
response = requests.post(url, json=data)
print(response.status_code)