0
0
Rest APIprogramming~10 mins

PATCH for partial updates in Rest API - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to specify the HTTP method for a partial update.

Rest API
response = requests.[1](url, json=data)
Drag options to blanks, or click blank then click option'
Aget
Bdelete
Cpost
Dpatch
Attempts:
3 left
💡 Hint
Common Mistakes
Using POST instead of PATCH for partial updates.
2fill in blank
medium

Complete the code to send only the 'email' field in the PATCH request.

Rest API
data = [1]
Drag options to blanks, or click blank then click option'
A'email=new@example.com'
B['email', 'new@example.com']
C{'email': 'new@example.com'}
D('email', 'new@example.com')
Attempts:
3 left
💡 Hint
Common Mistakes
Using a list or tuple instead of a dictionary for JSON data.
3fill in blank
hard

Fix the error in the PATCH request code by completing the missing header.

Rest API
headers = {'Content-Type': [1]
response = requests.patch(url, json=data, headers=headers)
Drag options to blanks, or click blank then click option'
A'application/xml'
B'application/json'
C'text/plain'
D'multipart/form-data'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong Content-Type header causing server to reject the request.
4fill in blank
hard

Fill both blanks to create a PATCH request that updates the 'name' field only.

Rest API
data = [1]
response = requests.[2](url, json=data)
Drag options to blanks, or click blank then click option'
A{'name': 'Alice'}
Bpost
Cpatch
D{'email': 'alice@example.com'}
Attempts:
3 left
💡 Hint
Common Mistakes
Using POST instead of PATCH or wrong data dictionary.
5fill in blank
hard

Fill all three blanks to send a PATCH request updating 'phone' and setting the correct header.

Rest API
data = [1]
headers = {'Content-Type': [2]
response = requests.[3](url, json=data, headers=headers)
Drag options to blanks, or click blank then click option'
A{'phone': '123-456-7890'}
B'application/json'
Cpatch
D{'phone': '987-654-3210'}
Attempts:
3 left
💡 Hint
Common Mistakes
Incorrect header or method, or wrong data format.