Consider a REST API endpoint that deletes multiple users by IDs passed as query parameters.
What is the expected HTTP response status code when the following DELETE request is successful?
DELETE /users?ids=1,2,3
Think about the standard REST practice for successful DELETE requests with no content returned.
204 No Content is the standard response for successful DELETE requests when no response body is returned. Returning 200 OK with a body is possible but less common. 404 or 500 indicate errors.
A REST API supports batch deletion by sending a JSON array of IDs in the request body.
Given this request:
DELETE /items Content-Type: application/json [10, 20, 30]
What is the expected output if items 10 and 20 exist but 30 does not?
Consider how partial success is usually reported in batch operations.
When some items are deleted and some are missing, the API commonly returns a JSON object listing which were deleted and which were not found. 204 No Content would not convey partial success. 404 or 400 would reject the entire request.
Why is idempotency important in batch delete REST API endpoints?
Think about what happens if a client sends the same delete request multiple times.
Idempotency means that making the same request multiple times has the same effect as making it once. This prevents errors or unintended side effects from repeated requests.
A batch delete API returns this JSON response:
{"deleted": [1, 2], "errors": [{"id": 3, "message": "Permission denied"}]}What is the most likely cause of this partial failure?
Look at the error message associated with ID 3.
The error message "Permission denied" indicates the user is not authorized to delete item 3, causing partial failure while other items were deleted successfully.
Which of the following HTTP DELETE requests correctly uses a JSON body to batch delete resources?
Consider the correct use of HTTP method, URL, headers, and body format for batch delete.
Option B correctly sends a DELETE request to the resource endpoint with a JSON body containing an object with an "ids" array. Option B sends a JSON array directly which some APIs may not accept. Option B uses an invalid URL format. Option B uses wrong content type and body format.