Bird
0
0

You want to design a batch delete endpoint for a REST API that deletes multiple products by IDs sent in the request body as JSON. Which approach is best practice?

hard📝 Application Q15 of 15
Rest API - Batch and Bulk Operations

You want to design a batch delete endpoint for a REST API that deletes multiple products by IDs sent in the request body as JSON. Which approach is best practice?

{
  "ids": [101, 102, 103]
}

Choose the correct method and request format.

AUse DELETE method with JSON body containing IDs array.
BUse POST method with JSON body containing IDs array.
CUse DELETE method with IDs in query string separated by commas.
DUse GET method with IDs in URL path.
Step-by-Step Solution
Solution:
  1. Step 1: Understand REST conventions for delete

    DELETE method is standard for removing resources, including batch deletes.
  2. Step 2: Check request body usage

    Modern APIs allow DELETE with JSON body to specify multiple IDs for batch delete.
  3. Step 3: Evaluate options

    POST is not for deletion, GET is for retrieval, query string can be limited in length.
  4. Final Answer:

    Use DELETE method with JSON body containing IDs array. -> Option A
  5. Quick Check:

    DELETE + JSON body for batch delete = best practice [OK]
Quick Trick: Use DELETE with JSON body for multiple IDs batch delete [OK]
Common Mistakes:
MISTAKES
  • Using POST instead of DELETE for deletion
  • Putting IDs in query string risking URL length limits
  • Using GET which is not for deletion

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes