0
0
Rest APIprogramming~10 mins

Bulk import and export 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 bulk import.

Rest API
response = requests.[1]('https://api.example.com/bulk/import', json=data)
Drag options to blanks, or click blank then click option'
Aput
Bget
Cdelete
Dpost
Attempts:
3 left
💡 Hint
Common Mistakes
Using GET instead of POST
Using DELETE which removes data
2fill in blank
medium

Complete the code to specify the correct content type header for bulk export.

Rest API
headers = {'Content-Type': '[1]'}
Drag options to blanks, or click blank then click option'
Aapplication/json
Btext/plain
Capplication/xml
Dmultipart/form-data
Attempts:
3 left
💡 Hint
Common Mistakes
Using text/plain which is plain text
Using multipart/form-data which is for file uploads
3fill in blank
hard

Fix the error in the code to correctly parse the bulk export response JSON.

Rest API
data = response.[1]()
Drag options to blanks, or click blank then click option'
Atext
Bjson
Craw
Dcontent
Attempts:
3 left
💡 Hint
Common Mistakes
Using text() which returns string
Using content which returns bytes
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that filters bulk import data for items with quantity greater than 10.

Rest API
filtered_data = {item['id']: item for item in data if item[1] [2] 10}
Drag options to blanks, or click blank then click option'
A['quantity']
B>
C<
D['price']
Attempts:
3 left
💡 Hint
Common Mistakes
Using price instead of quantity
Using less than operator
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps uppercase item names to their prices for items with price less than 100.

Rest API
result = [1]: [2] for [3] in items if item['price'] < 100
Drag options to blanks, or click blank then click option'
Aitem['name'].upper()
Bitem['price']
Citem
Ditem['name']
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase names
Using item instead of item['price'] for values