Given this JSON response from a REST API representing an order, what is the value of the href for the cancel action link?
{
"orderId": "12345",
"status": "processing",
"actions": {
"cancel": {
"href": "/orders/12345/cancel",
"method": "POST"
},
"track": {
"href": "/orders/12345/track",
"method": "GET"
}
}
}Look for the cancel key inside actions and check its href value.
The cancel action link is defined with href as /orders/12345/cancel. This is the correct URL to trigger the cancel action for order 12345.
In REST APIs, when you provide action links for state transitions such as 'approve' or 'reject' an item, which HTTP method is most appropriate to use?
Think about methods that cause a change in server state but are not idempotent.
POST is commonly used for state transitions that cause a change but are not idempotent, such as 'approve' or 'reject'. GET is for retrieval, DELETE for removal, and PUT for idempotent updates.
What error will occur when a client tries to use this action link to transition the state?
{
"actions": {
"ship": {
"href": "/orders/789/ship",
"method": "GET"
}
}
}Consider HTTP method semantics for state changes.
GET should be safe and not change state. Using GET for a state transition like 'ship' is incorrect and can cause unexpected behavior or violate REST principles.
Choose the syntactically correct JSON snippet for an action link named 'complete' that uses POST method.
Remember JSON requires double quotes around keys and string values.
Option A is valid JSON with proper quotes and syntax. Option A misses quotes around keys, C misses quotes around method value, D is missing closing brace.
Given this JSON snippet for a resource, count the number of action links and list their HTTP methods.
{
"id": "555",
"status": "pending",
"actions": {
"approve": { "href": "/requests/555/approve", "method": "POST" },
"reject": { "href": "/requests/555/reject", "method": "POST" },
"cancel": { "href": "/requests/555/cancel", "method": "DELETE" }
}
}Count all keys inside the actions object and note their methods.
There are three action links: 'approve' (POST), 'reject' (POST), and 'cancel' (DELETE).