0
0
Rest APIprogramming~20 mins

Batch update patterns in Rest API - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Batch Update Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of this batch update response?

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?

A0
B3
C1
D2
Attempts:
2 left
💡 Hint

Count how many items have status "updated" in the results array.

🧠 Conceptual
intermediate
1:30remaining
Which HTTP method is most appropriate for batch updates?

You want to update multiple resources in a single REST API call. Which HTTP method should you use according to REST principles?

APOST
BPUT
CGET
DDELETE
Attempts:
2 left
💡 Hint

Think about which method is used to replace or update resources.

🔧 Debug
advanced
2:00remaining
Why does this batch update API return a 400 error?

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?

AServer timeout
BInvalid HTTP method used
CMissing 'id' field in one update object
DEmpty updates array
Attempts:
2 left
💡 Hint

Check if all update objects have required fields.

📝 Syntax
advanced
1:30remaining
Which JSON payload is valid for a batch update?

Choose the valid JSON payload for updating multiple items in one request.

A{ "updates": [{ "id": 1, "value": "x" }, { "id": 2, "value": "y" }] }
B{ "updates": { "id": 1, "value": "x" }, { "id": 2, "value": "y" } }
C[ { "id": 1, "value": "x" }, { "id": 2, "value": "y" } ]
D{ "updates": [ { "id": 1, "value": "x" }, { "id": 2, "value": "y" } ] }
Attempts:
2 left
💡 Hint

Check for proper JSON object and array syntax.

🚀 Application
expert
2:30remaining
How many items are updated after this batch request?

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?

A3
B4
C2
D1
Attempts:
2 left
💡 Hint

Count how many results have status "updated".