Bird
0
0

Given this batch create endpoint code snippet, what will be the response if one item is invalid?

medium📝 Predict Output Q13 of 15
Rest API - Batch and Bulk Operations
Given this batch create endpoint code snippet, what will be the response if one item is invalid?
POST /items/batch
Request body: [{"name": "item1"}, {"name": ""}]

Response: 400 Bad Request
{
  "error": "Validation failed",
  "details": [{"index": 1, "message": "Name cannot be empty"}]
}
AServer crashes due to invalid input
BAll items are created, ignoring the invalid one
COnly the valid items are created, error ignored
DNo items are created, and error details are returned
Step-by-Step Solution
Solution:
  1. Step 1: Understand validation behavior in batch create

    If any item is invalid, the server should reject the whole batch to keep data consistent.
  2. Step 2: Analyze the response code and message

    Response 400 with error details means no items were created and client is informed.
  3. Final Answer:

    No items are created, and error details are returned -> Option D
  4. Quick Check:

    Validation failure returns 400 with errors [OK]
Quick Trick: Validation errors cause full batch rejection [OK]
Common Mistakes:
MISTAKES
  • Assuming partial success without error
  • Ignoring error details in response
  • Expecting server to crash on bad input

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes