Bird
0
0

You want to design an API endpoint that allows clients to safely check if a resource exists without modifying it. Which HTTP method should you use and why?

hard📝 Application Q8 of 15
Rest API - HTTP Methods
You want to design an API endpoint that allows clients to safely check if a resource exists without modifying it. Which HTTP method should you use and why?
ADELETE, because it removes the resource
BPOST, because it creates a new resource
CHEAD, because it retrieves headers without body and is safe
DPUT, because it updates the resource
Step-by-Step Solution
Solution:
  1. Step 1: Identify method for safe existence check

    HEAD requests retrieve headers only, no body, and do not modify data.
  2. Step 2: Match method to requirement

    HEAD is ideal to check resource existence safely.
  3. Final Answer:

    HEAD, because it retrieves headers without body and is safe -> Option C
  4. Quick Check:

    Safe existence check = HEAD [OK]
Quick Trick: HEAD checks resource existence safely without body [OK]
Common Mistakes:
MISTAKES
  • Using POST for checking existence
  • Confusing DELETE with safe method
  • Using PUT incorrectly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes