Bird
0
0

Identify the error in this HAL JSON snippet:

medium📝 Debug Q6 of 15
Rest API - HATEOAS and Linking
Identify the error in this HAL JSON snippet:
{
  "_links": {
    "self": "/users/5"
  }
}
AThe _links key should be named _embedded
BThe 'self' link should be an object with an href property
CThe URL should be an array, not a string
DThe JSON is missing a _meta section
Step-by-Step Solution
Solution:
  1. Step 1: Check the structure of the 'self' link

    In HAL, links must be objects with an href property, not just strings.
  2. Step 2: Verify other options

    _links is correctly named, URLs are strings not arrays, and _meta is optional.
  3. Final Answer:

    The 'self' link should be an object with an href property -> Option B
  4. Quick Check:

    Links require href objects, not strings [OK]
Quick Trick: Always wrap link URLs in an object with href [OK]
Common Mistakes:
  • Using string instead of object for links
  • Renaming _links incorrectly
  • Expecting arrays for URLs

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes