0
0
Rest APIprogramming~10 mins

Why hypermedia drives discoverability 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 add a hypermedia link to the API response.

Rest API
response = {"data": user_data, "_links": {"self": [1]
Drag options to blanks, or click blank then click option'
A"/api/users/123"
B"user_data"
C"data"
D"/api/data"
Attempts:
3 left
💡 Hint
Common Mistakes
Using the data variable name instead of a URL string.
Omitting quotes around the URL string.
2fill in blank
medium

Complete the code to include a hypermedia link for the 'next' page in pagination.

Rest API
response["_links"]["next"] = [1]
Drag options to blanks, or click blank then click option'
A"/api/users?page=2"
B"/api/users?page=3"
C"/api/users?page=1"
D"/api/users?page=0"
Attempts:
3 left
💡 Hint
Common Mistakes
Using the current page number instead of the next page.
Using an invalid page number like 0.
3fill in blank
hard

Fix the error in the hypermedia response by completing the blank.

Rest API
response = {"data": items, "_links": {"self": "/api/items", "related": [1]
Drag options to blanks, or click blank then click option'
A"api/items/related"
Bitems
C"related"
D"/api/items/related"
Attempts:
3 left
💡 Hint
Common Mistakes
Using variable names instead of URL strings.
Missing the leading slash in the URL.
4fill in blank
hard

Fill both blanks to create a hypermedia-driven response with conditional links.

Rest API
response = {"data": [1], "_links": {"self": "/api/data", "next": [2]
Drag options to blanks, or click blank then click option'
Aitems
B"/api/data?page=2"
C"/api/data?page=3"
Ddata
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong variable name for data.
Setting the 'next' link to an incorrect page.
5fill in blank
hard

Fill all three blanks to build a hypermedia response with filtered data and links.

Rest API
filtered = [item for item in all_items if item['type'] == [1]]
response = {"data": filtered, "_links": {"self": [2], "related": [3]
Drag options to blanks, or click blank then click option'
A"book"
B"/api/items?type=book"
C"/api/items/related"
Attempts:
3 left
💡 Hint
Common Mistakes
Using variable names instead of string literals for filtering.
Omitting quotes around URL strings.