Bird
0
0

An API uses DELETE to remove a resource and POST to create it. To make the creation idempotent, what strategy can be applied?

hard📝 Application Q9 of 15
Rest API - HTTP Methods
An API uses DELETE to remove a resource and POST to create it. To make the creation idempotent, what strategy can be applied?
ASend DELETE twice before POST
BUse POST with a unique client-generated ID to avoid duplicates
CSwitch POST to GET method
DUse POST without any identifiers
Step-by-Step Solution
Solution:
  1. Step 1: Understand POST non-idempotency

    POST creates new resources and can cause duplicates if repeated.
  2. Step 2: Apply idempotency strategy

    Using a unique client-generated ID in POST allows the server to recognize duplicates and avoid creating multiple resources.
  3. Final Answer:

    Use POST with a unique client-generated ID to avoid duplicates -> Option B
  4. Quick Check:

    Idempotent POST = unique client ID [OK]
Quick Trick: Add unique ID in POST to make creation idempotent [OK]
Common Mistakes:
  • Switching POST to GET incorrectly
  • Sending DELETE twice unnecessarily
  • Using POST without identifiers

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes