Bird
0
0

Given a REST API resource at /products/10 with data {"name":"Pen","price":1.5,"stock":100}, what will be the resource data after this PUT request body is sent?

medium📝 Predict Output Q4 of 15
Rest API - HTTP Methods
Given a REST API resource at /products/10 with data {"name":"Pen","price":1.5,"stock":100}, what will be the resource data after this PUT request body is sent?
{"name":"Pencil","price":0.5}
A{"name":"Pencil","price":0.5}
B{"name":"Pencil","price":0.5,"stock":100}
C{"name":"Pen","price":1.5,"stock":100}
D{"name":"Pencil"}
Step-by-Step Solution
Solution:
  1. Step 1: Understand PUT replaces entire resource

    The new data fully replaces the old resource, so only provided fields remain.
  2. Step 2: Identify missing fields effect

    Since "stock" is missing, it will be removed from the resource.
  3. Final Answer:

    {"name":"Pencil","price":0.5} -> Option A
  4. Quick Check:

    PUT replaces resource fully, missing fields removed [OK]
Quick Trick: PUT replaces all fields; missing fields disappear [OK]
Common Mistakes:
MISTAKES
  • Assuming missing fields stay unchanged
  • Expecting partial update behavior
  • Confusing PUT with PATCH

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes