Bird
Raised Fist0

Which of the following is the correct way to include hypermedia links in a JSON REST API response?

easy📝 Syntax Q12 of Q15
Rest API - HATEOAS and Linking
Which of the following is the correct way to include hypermedia links in a JSON REST API response?
A{"data": {...}, "links": {"self": "/items/1", "next": "/items/2"}}
B{"data": {...}, "url": "/items/1", "next_url": "/items/2"}
C{"data": {...}, "endpoint": "/items/1", "next_endpoint": "/items/2"}
D{"data": {...}, "link": "/items/1", "nextlink": "/items/2"}
Step-by-Step Solution
Solution:
  1. Step 1: Identify standard hypermedia link structure

    Hypermedia links are usually grouped under a "links" key with named relations like "self" and "next".
  2. Step 2: Compare options to standard

    {"data": {...}, "links": {"self": "/items/1", "next": "/items/2"}} uses "links" with "self" and "next" keys, matching common hypermedia patterns like HAL or JSON API.
  3. Final Answer:

    {"data": {...}, "links": {"self": "/items/1", "next": "/items/2"}} -> Option A
  4. Quick Check:

    Hypermedia links use "links" with relation names [OK]
Quick Trick: Look for "links" key with "self" and "next" [OK]
Common Mistakes:
MISTAKES
  • Using generic keys like "url" or "endpoint"
  • Not grouping links under a "links" object
  • Using singular "link" instead of plural

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes