Bird
0
0

Given this PATCH request body to update a product:

medium📝 Predict Output Q13 of 15
Rest API - HTTP Methods
Given this PATCH request body to update a product:
{"price": 19.99}
What will be the result if the original product data was
{"name": "Book", "price": 25.00, "stock": 10}
?
A{"name": "Book", "price": 25.00, "stock": 10}
B{"price": 19.99}
C{"name": "Book", "price": 19.99, "stock": 10}
D{"name": "Book", "stock": 10}
Step-by-Step Solution
Solution:
  1. Step 1: Understand PATCH partial update

    PATCH updates only the fields sent, here "price" changes to 19.99.
  2. Step 2: Combine unchanged fields with updated field

    Fields not in PATCH body remain unchanged, so "name" and "stock" stay the same.
  3. Final Answer:

    {"name": "Book", "price": 19.99, "stock": 10} -> Option C
  4. Quick Check:

    PATCH updates price only, others unchanged [OK]
Quick Trick: PATCH changes only sent fields, keeps others [OK]
Common Mistakes:
MISTAKES
  • Replacing entire object instead of partial update
  • Removing fields not in PATCH body
  • Ignoring updated field in result

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes