0
0
Rest APIprogramming~10 mins

Media type versioning 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 set the media type version in the Accept header.

Rest API
headers = {"Accept": "application/vnd.example.v[1]+json"}
Drag options to blanks, or click blank then click option'
A1
Bv1
Cjson
Dversion1
Attempts:
3 left
💡 Hint
Common Mistakes
Including the 'v' in the version number again.
Using 'json' instead of the version number.
2fill in blank
medium

Complete the code to check if the client requested version 2 in the Accept header.

Rest API
if request.headers.get('Accept') == 'application/vnd.example.v[1]+json':
    process_version_2()
Drag options to blanks, or click blank then click option'
A2
B1
Cv2
Djson
Attempts:
3 left
💡 Hint
Common Mistakes
Adding an extra 'v' before the version number.
Using 'json' instead of the version number.
3fill in blank
hard

Fix the error in the media type versioning string to correctly specify version 3.

Rest API
media_type = "application/vnd.example.[1]+json"
Drag options to blanks, or click blank then click option'
Aversion3
Bv3
C3
Dv.3
Attempts:
3 left
💡 Hint
Common Mistakes
Using '3' alone without 'v'.
Adding dots or extra words in the version part.
4fill in blank
hard

Fill both blanks to create a response with version 1 media type and JSON content.

Rest API
response.headers['Content-Type'] = 'application/vnd.example.[1]+[2]'
Drag options to blanks, or click blank then click option'
Av1
Bjson
Cxml
Dv2
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing version and format values.
Using 'xml' instead of 'json' for JSON content.
5fill in blank
hard

Fill all three blanks to build a media type versioning Accept header for version 4 with XML format.

Rest API
accept_header = 'application/vnd.example.[1]+[2]; charset=[3]'
Drag options to blanks, or click blank then click option'
Av4
Bxml
Cutf-8
Djson
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'json' instead of 'xml' for XML format.
Omitting charset or using wrong encoding.