Bird
0
0

Consider this PATCH request payload:

medium📝 Predict Output Q4 of 15
Rest API - Batch and Bulk Operations
Consider this PATCH request payload:
[{"userId":10,"role":"admin"},{"userId":15,"role":"editor"}]

What is the expected server behavior upon receiving this batch update?
AReturn an error because batch updates must use PUT
BCreate new users with the specified roles
CUpdate the roles of users with IDs 10 and 15 accordingly
DIgnore the request because PATCH does not support arrays
Step-by-Step Solution
Solution:
  1. Step 1: Analyze payload

    The payload contains multiple objects each specifying a userId and a new role.
  2. Step 2: Understand PATCH semantics

    PATCH supports partial updates; here it updates roles for specified users.
  3. Step 3: Evaluate options

    Update the roles of users with IDs 10 and 15 accordingly matches expected behavior; others are incorrect due to misuse of HTTP methods or misunderstanding.
  4. Final Answer:

    Update the roles of users with IDs 10 and 15 accordingly -> Option C
  5. Quick Check:

    PATCH updates specified fields in batch [OK]
Quick Trick: PATCH with array updates multiple resources [OK]
Common Mistakes:
MISTAKES
  • Assuming PATCH creates new resources
  • Believing batch updates require PUT method
  • Thinking PATCH cannot handle arrays

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes