0
0
Rest APIprogramming~10 mins

Why status codes communicate outcomes in Rest API - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
A200
B404
C500
D302
Attempts:
3 left
💡 Hint
Common Mistakes
Using 404 or 500 which mean errors.
2fill in blank
medium

Complete 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'
A404
B201
C400
D503
Attempts:
3 left
💡 Hint
Common Mistakes
Using 400 which means bad request, not not found.
3fill in blank
hard

Fix 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'
A200
B404
C500
D301
Attempts:
3 left
💡 Hint
Common Mistakes
Using 404 which means not found, not server error.
4fill in blank
hard

Fill 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'
A302
B'/new-page'
C'/home'
D404
Attempts:
3 left
💡 Hint
Common Mistakes
Using 404 as status code for redirect.
5fill in blank
hard

Fill 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'
A{'message': 'Success'}
B200
C{}
D{'Content-Type': 'application/json'}
Attempts:
3 left
💡 Hint
Common Mistakes
Leaving headers empty or missing content type.