Consider a REST API that accepts a batch update request for multiple user records. The server responds with a JSON object summarizing the update results.
{
"results": [
{"id": 1, "status": "updated"},
{"id": 2, "status": "not_found"},
{"id": 3, "status": "updated"}
],
"summary": {
"updated": 2,
"not_found": 1
}
}What is the value of response.summary.updated?
Count how many items have status "updated" in the results array.
The summary field shows the count of updated records. Since two records have status "updated", the value is 2.
You want to update multiple resources in a single REST API call. Which HTTP method should you use according to REST principles?
Think about which method is used to replace or update resources.
PUT is used to update or replace resources. For batch updates, a PUT request with a list of updates is appropriate.
Given this batch update request payload:
{
"updates": [
{"id": 1, "name": "Alice"},
{"name": "Bob"}
]
}The server responds with HTTP 400 Bad Request. What is the most likely cause?
Check if all update objects have required fields.
Each update must specify the resource ID to update. The second object lacks 'id', causing the 400 error.
Choose the valid JSON payload for updating multiple items in one request.
Check for proper JSON object and array syntax.
Option A correctly wraps the array in an object with key 'updates' and uses proper JSON syntax.
A batch update request sends the following payload:
{
"updates": [
{"id": 1, "status": "active"},
{"id": 2, "status": "inactive"},
{"id": 3, "status": "active"},
{"id": 4, "status": "active"}
]
}The server processes the batch and returns this response:
{
"results": [
{"id": 1, "status": "updated"},
{"id": 2, "status": "error", "message": "Invalid status"},
{"id": 3, "status": "updated"},
{"id": 4, "status": "updated"}
]
}How many items were successfully updated?
Count how many results have status "updated".
Three items have status "updated"; one has an error.