Bird
0
0

What will be the final address stored?

hard📝 Application Q9 of 15
Rest API - HTTP Methods
A REST API uses PUT to replace a nested resource like /users/5/address. The original address is {"street":"1st Ave","city":"NY","zip":"10001"}. The client sends a PUT with {"street":"2nd Ave","city":"NY"}. What will be the final address stored?
A{"street":"2nd Ave"}
B{"street":"2nd Ave","city":"NY","zip":"10001"}
C{"street":"1st Ave","city":"NY","zip":"10001"}
D{"street":"2nd Ave","city":"NY"}
Step-by-Step Solution
Solution:
  1. Step 1: PUT replaces the entire nested resource

    The new address fully replaces the old one, so missing fields are removed.
  2. Step 2: Missing "zip" field is deleted

    Since "zip" is not in the PUT body, it will be removed from the stored address.
  3. Final Answer:

    {"street":"2nd Ave","city":"NY"} -> Option D
  4. Quick Check:

    PUT replaces nested resource fully, missing fields removed [OK]
Quick Trick: PUT replaces nested resource fully; missing fields removed [OK]
Common Mistakes:
  • Assuming nested missing fields stay
  • Confusing PUT with PATCH
  • Expecting partial update on nested resource

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes