Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to add an action link for the 'approve' transition.
Rest API
{
"state": "pending",
"actions": [
{"name": "approve", "href": "/orders/[1]/approve"}
]
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a literal number instead of a placeholder.
Using an underscore style that is inconsistent with the rest of the API.
✗ Incorrect
The 'id' placeholder is commonly used to represent the resource identifier in REST API URLs.
2fill in blank
mediumComplete the code to add an action link for the 'cancel' transition with HTTP method DELETE.
Rest API
{
"state": "approved",
"actions": [
{"name": "cancel", "href": "/orders/[1]/cancel", "method": "[2]"}
]
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'POST' instead of 'DELETE' for cancel action.
Using a wrong placeholder for the resource id.
✗ Incorrect
The 'id' is the resource identifier and 'DELETE' is the HTTP method used to cancel or remove a resource.
3fill in blank
hardFix the error in the action link for the 'ship' transition by completing the HTTP method.
Rest API
{
"state": "paid",
"actions": [
{"name": "ship", "href": "/orders/[1]/ship", "method": "[2]"}
]
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'GET' which is for retrieving data, not updating.
Using 'PATCH' which is for partial updates but 'ship' implies a full state change.
✗ Incorrect
The 'ship' action updates the order state, so 'PUT' is the appropriate HTTP method to update the resource.
4fill in blank
hardFill both blanks to add action links for 'approve' and 'reject' transitions with correct HTTP methods.
Rest API
{
"state": "pending",
"actions": [
{"name": "approve", "href": "/orders/[1]/approve", "method": "[2]"},
{"name": "reject", "href": "/orders/[1]/reject", "method": "[2]"}
]
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different identifiers for the two actions.
Using 'PUT' or 'DELETE' instead of 'POST' for these transitions.
✗ Incorrect
Both 'approve' and 'reject' are state transitions that create a new state, so 'POST' is the correct HTTP method and 'id' is the resource identifier.
5fill in blank
hardFill all three blanks to create an action link for 'refund' with resource id, HTTP method, and content type.
Rest API
{
"state": "shipped",
"actions": [
{
"name": "refund",
"href": "/orders/[1]/refund",
"method": "[2]",
"headers": {"Content-Type": "[3]"}
}
]
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'PUT' instead of 'POST' for refund.
Omitting the content type or using an incorrect one.
✗ Incorrect
The 'refund' action uses the resource 'id', the 'POST' method to submit the refund request, and the content type 'application/json' for the request body.