Bird
Raised Fist0

Find the mistake in this HAL response snippet:

medium📝 Debug Q7 of Q15
Rest API - HATEOAS and Linking
Find the mistake in this HAL response snippet:
{
  "_embedded": {
    "orders": [
      { "id": 1, "total": 100 },
      { "id": 2, "total": 150 }
    ]
  },
  "_links": {
    "self": { "href": "/customers/1" }
  }
}
AThe orders inside _embedded should be objects with _links
BThe _embedded key should be named _links
CThe orders array should be inside _links, not _embedded
DThe self link href is missing a trailing slash
Step-by-Step Solution
Solution:
  1. Step 1: Understand embedded resource structure

    In HAL, embedded resources usually include their own _links section for navigation.
  2. Step 2: Check the orders array items

    Here, orders lack _links, which is a common mistake as embedded resources should have links.
  3. Final Answer:

    The orders inside _embedded should be objects with _links -> Option A
  4. Quick Check:

    Embedded resources need their own _links [OK]
Quick Trick: Embed resources should include their own _links for navigation [OK]
Common Mistakes:
MISTAKES
  • Ignoring _links inside embedded resources
  • Confusing _embedded and _links keys
  • Focusing on URL formatting instead

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes