0
0
Rest APIprogramming~10 mins

Response envelope patterns 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 create a basic response envelope with a status field.

Rest API
response = {"status": "[1]"}
Drag options to blanks, or click blank then click option'
Afailed
Berror
Cpending
Dsuccess
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'error' instead of 'success' for a successful response.
2fill in blank
medium

Complete the code to add a data field to the response envelope.

Rest API
response = {"status": "success", "[1]": {"id": 1, "name": "Item"}}
Drag options to blanks, or click blank then click option'
Aerror
Bdata
Cmessage
Dresult
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'error' or 'message' instead of 'data' for the content field.
3fill in blank
hard

Fix the error in the response envelope by completing the missing key for error details.

Rest API
response = {"status": "error", "[1]": "Invalid request parameters."}
Drag options to blanks, or click blank then click option'
Amessage
Berror
Cresult
Ddata
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'data' or 'result' keys for error messages.
4fill in blank
hard

Fill both blanks to create a response envelope with status and nested data count.

Rest API
response = {"[1]": "success", "data": {"count": [2]
Drag options to blanks, or click blank then click option'
Astatus
Btotal
Citems
D5
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'total' or 'items' as the status key.
Putting a string instead of a number for count.
5fill in blank
hard

Fill all three blanks to create a full response envelope with status, data list, and message.

Rest API
response = {"[1]": "success", "[2]": [{"id": 1}, {"id": 2}], "[3]": "Request completed."}
Drag options to blanks, or click blank then click option'
Astatus
Bdata
Cmessage
Derror
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up 'error' with 'message' or 'data'.