Bird
0
0

You want to provide navigation links for first, previous, next, and last pages in your API response. Which of the following Link header values correctly includes all these relations?

hard📝 Application Q15 of 15
Rest API - Pagination Patterns
You want to provide navigation links for first, previous, next, and last pages in your API response. Which of the following Link header values correctly includes all these relations?
ALink: <https://api.example.com/items?page=1>; rel="first", <https://api.example.com/items?page=2>; rel="prev", <https://api.example.com/items?page=4>; rel="next", <https://api.example.com/items?page=10>; rel="last"
BLink: <https://api.example.com/items?page=1>; rel first, <https://api.example.com/items?page=2>; rel=prev, <https://api.example.com/items?page=4>; rel=next, <https://api.example.com/items?page=10>; rel=last
CLink: <https://api.example.com/items?page=1> first, <https://api.example.com/items?page=2> prev, <https://api.example.com/items?page=4> next, <https://api.example.com/items?page=10> last
DLink: rel="first" <https://api.example.com/items?page=1>, rel="prev" <https://api.example.com/items?page=2>, rel="next" <https://api.example.com/items?page=4>, rel="last" <https://api.example.com/items?page=10>
Step-by-Step Solution
Solution:
  1. Step 1: Confirm correct Link header syntax

    The correct format is Link: <URL>; rel="relation", <URL>; rel="relation" etc., with URL in <>, semicolon, rel= with value in quotes.
  2. Step 2: Evaluate each option

    Link: <https://api.example.com/items?page=1>; rel="first", <https://api.example.com/items?page=2>; rel="prev" etc. matches exactly. The similar one has 'rel first' (missing = after rel). Others miss semicolons, have rel before URL, or wrong separators.
  3. Final Answer:

    Link: <https://api.example.com/items?page=1>; rel="first", <https://api.example.com/items?page=2>; rel="prev", <https://api.example.com/items?page=4>; rel="next", <https://api.example.com/items?page=10>; rel="last" -> Option A
  4. Quick Check:

    All links with <> and rel="relation" separated by commas [OK]
Quick Trick: Use <URL>; rel="relation" for each link, separated by commas [OK]
Common Mistakes:
  • Placing rel before URL
  • Missing semicolons between URL and rel
  • Not separating links with commas

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes