Bird
0
0

What is the resource after the PUT?

medium📝 Predict Output Q5 of 15
Rest API - HTTP Methods
A client sends a PUT request to /users/7 with body {"username":"alice","email":"alice@example.com"}. The original resource was {"username":"alice","email":"old@example.com","age":30}. What is the resource after the PUT?
A{"username":"alice","email":"alice@example.com","age":30}
B{"username":"alice","email":"alice@example.com"}
C{"username":"alice","email":"old@example.com","age":30}
D{"username":"alice"}
Step-by-Step Solution
Solution:
  1. Step 1: Recognize PUT replaces entire resource

    The new data fully replaces the old resource at /users/7.
  2. Step 2: Missing "age" field is removed

    Since "age" is not in the PUT body, it is deleted from the resource.
  3. Final Answer:

    {"username":"alice","email":"alice@example.com"} -> Option B
  4. Quick Check:

    PUT replaces resource fully, missing fields removed [OK]
Quick Trick: PUT removes fields not in request body [OK]
Common Mistakes:
  • Expecting missing fields to remain
  • Confusing PUT with PATCH
  • Assuming partial update

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes