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.get("https://api.school.com/students/7") | APOST creates resources and does not delete them. Use DELETE to remove student 7. | |
| 2requests.delete("https://api.school.com/students/7") | Brequests.put(url, json=changes) # 404 | |
| 3POST creates a new resource, and the server replies 201 Created when it succeeds | Crequests.post(url, json=new_student) # 201 | |
| 4PUT updates an existing resource, and a 404 Not Found reply means that resource does not exist | DReads (retrieves) the student with ID 7 without changing anything on the server | |
| 5requests.get(url, json=new_student) # to create a student | EGET only reads data, so it cannot create a resource. Use POST to create a new student. | |
| 6requests.post(url) # to delete student 7 | FRemoves the student with ID 7 from the server |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
GET, POST, PUT, DELETE — HTTP methods in a REST API: GET reads a resource, POST creates one, PUT updates one and DELETE removes one. The server replies with a status code such as 200 OK or 404 Not Found.url = "https://api.example.com/students"
r = requests.get(url)
print(r.status_code)url = "https://api.example.com/students"
r = requests.post(url, json=new_student)url = "https://api.example.com/students/1"
r = requests.put(url, json=changes)url = "https://api.example.com/students/1"
r = requests.delete(url)r = requests.get(url)
if r.status_code == 404:
print("Student not found")