Bird
0
0

You need to delete multiple resources in a single REST API call. Which method aligns best with REST principles?

hard📝 Application Q8 of 15
Rest API - HTTP Methods
You need to delete multiple resources in a single REST API call. Which method aligns best with REST principles?
ASend a DELETE request to an endpoint like <code>/items</code> with a JSON body listing IDs to delete.
BSend multiple DELETE requests, one per resource ID.
CUse a GET request with query parameters specifying IDs to delete.
DSend a POST request to <code>/items/delete</code> with IDs in the body.
Step-by-Step Solution
Solution:
  1. Step 1: Understand batch deletion

    REST allows DELETE with a body listing multiple IDs for batch removal.
  2. Step 2: Evaluate options

    Multiple DELETE calls (B) is inefficient; GET (C) should not modify data; POST (D) is less RESTful.
  3. Final Answer:

    Send a DELETE request to /items with JSON body listing IDs. -> Option A
  4. Quick Check:

    Batch DELETE with body listing IDs [OK]
Quick Trick: Batch DELETE with JSON body listing IDs [OK]
Common Mistakes:
  • Using GET to delete resources
  • Sending multiple separate DELETE requests instead of batch
  • Using POST for deletion without clear REST justification

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes