Bird
0
0

You want to design an API endpoint to update user preferences that can be safely called multiple times without unintended effects. Which HTTP method should you choose?

hard📝 Application Q8 of 15
Rest API - HTTP Methods
You want to design an API endpoint to update user preferences that can be safely called multiple times without unintended effects. Which HTTP method should you choose?
APUT
BPOST
CPATCH
DOPTIONS
Step-by-Step Solution
Solution:
  1. Step 1: Identify safe repeated call requirement

    The method must be idempotent to avoid unintended effects on multiple calls.
  2. Step 2: Choose method that replaces resource safely

    PUT replaces the entire resource and is idempotent, making it suitable for updating preferences safely multiple times.
  3. Final Answer:

    PUT -> Option A
  4. Quick Check:

    Idempotent update = PUT [OK]
Quick Trick: Use PUT for safe repeated updates without side effects [OK]
Common Mistakes:
MISTAKES
  • Choosing POST which is not idempotent
  • Using PATCH which may cause side effects
  • Confusing OPTIONS with update method

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes