Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to return a successful HTTP status code.
Rest API
return Response(status=[1])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 404 or 500 which mean errors.
✗ Incorrect
The status code 200 means the request was successful.
2fill in blank
mediumComplete the code to return a 'Not Found' status code.
Rest API
return Response(status=[1])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 400 which means bad request, not not found.
✗ Incorrect
The status code 404 means the requested resource was not found.
3fill in blank
hardFix the error in the code to return a server error status code.
Rest API
return Response(status=[1])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 404 which means not found, not server error.
✗ Incorrect
The status code 500 means an internal server error occurred.
4fill in blank
hardFill both blanks to return a redirect status code and the new location.
Rest API
return Response(status=[1], headers={'Location': [2])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 404 as status code for redirect.
✗ Incorrect
302 is a redirect status code and 'Location' header tells where to go.
5fill in blank
hardFill all three blanks to return a JSON response with a success status and message.
Rest API
return Response(json=[1], status=[2], headers=[3])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Leaving headers empty or missing content type.
✗ Incorrect
The JSON contains the message, status 200 means success, and header sets content type.