Bird
0
0

You want to implement pagination links for an API returning 100 items with 10 items per page. Which Link header correctly provides navigation for page 5?

hard📝 Application Q15 of 15
Rest API - HATEOAS and Linking
You want to implement pagination links for an API returning 100 items with 10 items per page. Which Link header correctly provides navigation for page 5?
ALink: <https://api.example.com/items?page=4>; rel="next", <https://api.example.com/items?page=6>; rel="prev"
BLink: <https://api.example.com/items?page=6>; rel="next", <https://api.example.com/items?page=4>; rel="prev"
CLink: <https://api.example.com/items?page=5>; rel="next", <https://api.example.com/items?page=5>; rel="prev"
DLink: <https://api.example.com/items?page=7>; rel="next", <https://api.example.com/items?page=3>; rel="prev"
Step-by-Step Solution
Solution:
  1. Step 1: Calculate next and previous pages for page 5

    Next page after 5 is 6, previous page before 5 is 4.
  2. Step 2: Match correct URLs with rel attributes

    Link: ; rel="next", ; rel="prev" correctly assigns page=6 to rel="next" and page=4 to rel="prev".
  3. Final Answer:

    Link: <https://api.example.com/items?page=6>; rel="next", <https://api.example.com/items?page=4>; rel="prev" -> Option B
  4. Quick Check:

    Page 5 next=6, prev=4 [OK]
Quick Trick: Next page = current +1, prev page = current -1 in Link header [OK]
Common Mistakes:
  • Swapping next and prev URLs
  • Using current page number for both next and prev
  • Incorrect page numbers outside valid range

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes