Bird
0
0

You have a REST API for managing books with resource /books/{id}. You want to replace a book resource fully but keep the id unchanged. Which approach correctly uses PUT for this?

hard📝 Application Q8 of 15
Rest API - HTTP Methods
You have a REST API for managing books with resource /books/{id}. You want to replace a book resource fully but keep the id unchanged. Which approach correctly uses PUT for this?
ASend PUT to <code>/books/123</code> with full book data except <code>id</code> field omitted
BSend PUT to <code>/books/123</code> with full book data including <code>id</code> field set to 123
CSend PATCH to <code>/books/123</code> with partial data excluding <code>id</code>
DSend POST to <code>/books/123</code> with full book data including <code>id</code>
Step-by-Step Solution
Solution:
  1. Step 1: PUT requires full resource data including all fields

    To fully replace, all fields must be present, including the id.
  2. Step 2: Omitting id can cause inconsistency or errors

    The server expects the id to match the URL resource identifier.
  3. Final Answer:

    Send PUT to /books/123 with full book data including id field set to 123 -> Option B
  4. Quick Check:

    PUT full data includes id matching URL [OK]
Quick Trick: PUT full data must include id matching URL [OK]
Common Mistakes:
  • Omitting id field in PUT data
  • Using PATCH instead of PUT for full replacement
  • Using POST for update

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes