Bird
0
0

Consider this client code sending a POST request with an idempotency key:

medium📝 Predict Output Q5 of 15
Rest API - Advanced Patterns
Consider this client code sending a POST request with an idempotency key:
headers = {"Idempotency-Key": "abc123"}
response1 = send_post(data, headers)
response2 = send_post(data, headers)
If the server implements idempotency correctly, what will be true about response1 and response2?
AThey will have the same status code and identical results
BThey will have different status codes and results
CThe second request will fail with a 409 Conflict error
DThe server will ignore the idempotency key and process both
Step-by-Step Solution
Solution:
  1. Step 1: Understand idempotency key effect on repeated requests

    Requests with the same key should return the same response without reprocessing.
  2. Step 2: Compare expected responses

    Both responses should have the same status and content because the server caches the first response.
  3. Final Answer:

    They will have the same status code and identical results -> Option A
  4. Quick Check:

    Same key means same response [OK]
Quick Trick: Repeated requests with same key get identical responses [OK]
Common Mistakes:
MISTAKES
  • Expecting different results on retries
  • Thinking server returns error on duplicate key
  • Ignoring header usage for idempotency

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes