0
0
Rest APIprogramming~10 mins

Partial success handling 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 return a 207 status code for partial success.

Rest API
response.status_code = [1]
Drag options to blanks, or click blank then click option'
A500
B207
C404
D200
Attempts:
3 left
💡 Hint
Common Mistakes
Using 200 which means full success
Using 404 which means not found
Using 500 which means server error
2fill in blank
medium

Complete the code to include a list of failed items in the JSON response.

Rest API
response.json = {"failed_items": [1]
Drag options to blanks, or click blank then click option'
A["item1", "item2"]
B{}
C[]
DNone
Attempts:
3 left
💡 Hint
Common Mistakes
Using None which is not JSON serializable
Using empty list which means no failures
Using empty dict which is wrong type
3fill in blank
hard

Fix the error in the code to properly handle partial success response.

Rest API
if failed_items:
    return [1](json={"failed": failed_items}, status=207)
else:
    return success_response()
Drag options to blanks, or click blank then click option'
Arender_template
Bjsonify
Cmake_response
Dredirect
Attempts:
3 left
💡 Hint
Common Mistakes
Using jsonify which cannot set status code directly
Using render_template which is for HTML
Using redirect which is for URL redirection
4fill in blank
hard

Fill both blanks to create a partial success response with a message and failed items list.

Rest API
response = [1]({"message": "Partial success", "failed": [2], status=207)
Drag options to blanks, or click blank then click option'
Amake_response
Bjsonify
C[]
D["file1", "file2"]
Attempts:
3 left
💡 Hint
Common Mistakes
Using jsonify which cannot set status code directly
Using empty list for failed items
5fill in blank
hard

Fill all three blanks to build a detailed partial success response with status, message, and failed items count.

Rest API
response = [1]({"status": [2], "message": "Partial success", "failed_count": [3], status=207)
Drag options to blanks, or click blank then click option'
Amake_response
B207
Clen(failed_items)
Djsonify
Attempts:
3 left
💡 Hint
Common Mistakes
Using jsonify instead of make_response
Using string '207' instead of number 207
Using a wrong count value