Challenge - 5 Problems
HAL Format Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this HAL JSON snippet?
Given this HAL JSON snippet, what is the value of the 'self' link href?
Rest API
{
"_links": {
"self": { "href": "/orders/123" },
"next": { "href": "/orders/124" },
"find": { "href": "/orders{?id}", "templated": true }
},
"total": 1,
"_embedded": {
"orders": [
{ "id": 123, "status": "shipped" }
]
}
}Attempts:
2 left
💡 Hint
Look inside the _links object for the 'self' key.
✗ Incorrect
The 'self' link in HAL points to the current resource URL, which is '/orders/123' here.
🧠 Conceptual
intermediate1:30remaining
What is the purpose of the _embedded section in HAL?
In HAL format, what does the _embedded section do?
Attempts:
2 left
💡 Hint
Think about how HAL helps clients get related data in one response.
✗ Incorrect
The _embedded section holds related resources so clients can access them without extra requests.
🔧 Debug
advanced2:30remaining
What error does this HAL JSON cause?
This HAL JSON snippet is invalid. What error will it cause when parsed?
Rest API
{
"_links": {
"self": { "href": "/users/1" },
"friends": [
{ "href": "/users/2" },
{ "href": "/users/3" }
]
},
"name": "Alice",
"age": 30
}Attempts:
2 left
💡 Hint
Check JSON syntax carefully between properties.
✗ Incorrect
There is a missing comma after the 'name' property, causing a JSON syntax error.
📝 Syntax
advanced2:00remaining
Which option correctly represents a templated link in HAL?
Choose the correct HAL syntax for a templated link to search orders by id.
Attempts:
2 left
💡 Hint
Templated links use curly braces with question mark for optional query params.
✗ Incorrect
Option C correctly uses the URI template syntax with {?id} and sets templated to true.
🚀 Application
expert1:30remaining
How many items are in the embedded orders list?
Given this HAL JSON, how many orders are embedded inside the _embedded section?
{
"_links": {
"self": { "href": "/orders" }
},
"_embedded": {
"orders": [
{ "id": 101, "status": "pending" },
{ "id": 102, "status": "shipped" },
{ "id": 103, "status": "delivered" }
]
},
"count": 3
}
Attempts:
2 left
💡 Hint
Count the number of objects inside the orders array in _embedded.
✗ Incorrect
There are three order objects inside the orders array in the _embedded section.