Bird
0
0

What is wrong with this hypermedia response?

medium📝 Debug Q7 of 15
Rest API - HATEOAS and Linking
What is wrong with this hypermedia response?
{"data": {"name": "User"}, "links": {"next": null}}
A"links" key must be an array, not an object
B"data" should include an "id" field
CThe JSON is missing a closing brace
D"next" link should not be null; it should be omitted if no next resource
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the "next" link value

    The "next" link is set to null, which is not a valid link.
  2. Step 2: Understand best practice for absent links

    If no next resource exists, the "next" link should be omitted rather than set to null.
  3. Final Answer:

    "next" link should not be null; it should be omitted if no next resource -> Option D
  4. Quick Check:

    Omit absent links instead of null [OK]
Quick Trick: Omit links instead of setting them to null [OK]
Common Mistakes:
  • Expecting "id" is mandatory in data
  • Thinking "links" must be an array
  • Assuming JSON syntax error due to braces

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes