Bird
0
0

Which of the following is the correct way to represent a link to a 'self' resource in HAL JSON?

easy📝 Syntax Q12 of 15
Rest API - HATEOAS and Linking
Which of the following is the correct way to represent a link to a 'self' resource in HAL JSON?
A"_links": { "self": { "href": "/orders/123" } }
B"links": { "self": "/orders/123" }
C"_links": { "self": "/orders/123" }
D"_link": { "href": "/orders/123" }
Step-by-Step Solution
Solution:
  1. Step 1: Recall HAL syntax for links

    HAL requires a _links object with named links, each having an href property.
  2. Step 2: Check each option's structure

    "_links": { "self": { "href": "/orders/123" } } correctly uses _links with self containing an object with href. Others miss underscores, use wrong keys, or omit href.
  3. Final Answer:

    "_links": { "self": { "href": "/orders/123" } } -> Option A
  4. Quick Check:

    HAL link = _links + href [OK]
Quick Trick: HAL links always use _links and href keys [OK]
Common Mistakes:
  • Omitting underscore in _links
  • Using string instead of object for link value
  • Missing href property inside link

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes