0
0
Rest APIprogramming~10 mins

Human-readable error messages 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 human-readable error message with status 404.

Rest API
return {"error": "Resource not found"}, [1]
Drag options to blanks, or click blank then click option'
A404
B403
C500
D200
Attempts:
3 left
💡 Hint
Common Mistakes
Using 200 instead of 404 for an error response.
2fill in blank
medium

Complete the code to send a JSON error message with status 400 for bad input.

Rest API
return {"error": "Invalid input"}, [1]
Drag options to blanks, or click blank then click option'
A400
B500
C401
D404
Attempts:
3 left
💡 Hint
Common Mistakes
Using 500 which means server error instead of client error.
3fill in blank
hard

Fix the error in the code to return a human-readable error message with status 401.

Rest API
return {"error": "Unauthorized access"}, [1]
Drag options to blanks, or click blank then click option'
A400
B404
C401
D403
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing 401 with 403 which means forbidden.
4fill in blank
hard

Fill both blanks to return a JSON error message with status 500 and a message for server error.

Rest API
return {"error": [1], [2]
Drag options to blanks, or click blank then click option'
A"Internal server error"
B400
C500
D"Bad request"
Attempts:
3 left
💡 Hint
Common Mistakes
Using 400 status code with a server error message.
5fill in blank
hard

Fill all three blanks to return a JSON error message with a custom message, status 403, and a retry suggestion.

Rest API
return {"error": [1], "suggestion": [2], [3]
Drag options to blanks, or click blank then click option'
A"Access forbidden"
B"Try logging in again"
C403
D"Invalid credentials"
Attempts:
3 left
💡 Hint
Common Mistakes
Using status 401 instead of 403 for forbidden access.