0
0
Rest APIprogramming~10 mins

HAL format overview in Rest API - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define the main HAL JSON object with a _links section.

Rest API
{
  "_links": [1]
}
Drag options to blanks, or click blank then click option'
A"self": "/orders"
B["self", "/orders"]
C[{"href": "/orders"}]
D{"self": {"href": "/orders"}}
Attempts:
3 left
💡 Hint
Common Mistakes
Using an array instead of an object for _links
Missing the href key inside the link object
2fill in blank
medium

Complete the code to add an embedded resource named 'orders' with an empty array.

Rest API
{
  "_embedded": {
    "[1]": []
  }
}
Drag options to blanks, or click blank then click option'
Aorders
Bitems
Clinks
Dself
Attempts:
3 left
💡 Hint
Common Mistakes
Using reserved keys like 'self' or 'links' as embedded resource names
Using singular instead of plural resource names
3fill in blank
hard

Fix the error in the HAL link object by completing the href value correctly.

Rest API
{
  "_links": {
    "self": {"href": "[1]"}
  }
}
Drag options to blanks, or click blank then click option'
Aorders/123
B/orders/123
Chttp://orders/123
Dorders123
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting the leading slash in the href
Using invalid URL formats
4fill in blank
hard

Fill both blanks to create a HAL resource with a self link and an embedded orders array.

Rest API
{
  "_links": {
    "[1]": {"href": "/orders"}
  },
  "_embedded": {
    "[2]": []
  }
}
Drag options to blanks, or click blank then click option'
Aself
Bitems
Corders
Dlinks
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'links' instead of 'self' for the link key
Using 'items' instead of 'orders' for embedded resource
5fill in blank
hard

Fill all three blanks to create a HAL resource with a self link, embedded orders, and a property 'count' with value 5.

Rest API
{
  "_links": {
    "[1]": {"href": "/orders"}
  },
  "_embedded": {
    "[2]": []
  },
  "[3]": 5
}
Drag options to blanks, or click blank then click option'
Aself
Borders
Ccount
Ditems
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'items' instead of 'orders' for embedded resource
Using '_count' instead of 'count' for the property name