0
0
Rest APIprogramming~20 mins

Batch delete patterns in Rest API - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Batch Delete Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Batch delete using query parameters

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
A500 Internal Server Error if any user ID is invalid
B200 OK with a JSON body listing deleted user IDs
C404 Not Found if any user ID does not exist
D204 No Content with an empty response body
Attempts:
2 left
💡 Hint

Think about the standard REST practice for successful DELETE requests with no content returned.

Predict Output
intermediate
2:00remaining
Batch delete with JSON body payload

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?

A{"deleted": [10, 20], "not_found": [30]}
B204 No Content with empty body
C404 Not Found with error message for ID 30
D400 Bad Request due to invalid ID 30
Attempts:
2 left
💡 Hint

Consider how partial success is usually reported in batch operations.

🧠 Conceptual
advanced
2:00remaining
Idempotency in batch delete operations

Why is idempotency important in batch delete REST API endpoints?

ATo ensure repeated requests do not cause errors or duplicate deletions
BTo allow the server to reject duplicate requests automatically
CTo guarantee the server deletes all items regardless of request content
DTo require clients to send unique tokens with each request
Attempts:
2 left
💡 Hint

Think about what happens if a client sends the same delete request multiple times.

🔧 Debug
advanced
2:00remaining
Debugging batch delete with partial failure

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?

AThe request body format is invalid for ID 3
BItem with ID 3 does not exist in the database
CUser lacks permission to delete item with ID 3
DThe server crashed while deleting item 3
Attempts:
2 left
💡 Hint

Look at the error message associated with ID 3.

📝 Syntax
expert
2:00remaining
Correct batch delete request format

Which of the following HTTP DELETE requests correctly uses a JSON body to batch delete resources?

A
DELETE /resources
Content-Type: text/plain

ids=5,6,7
B
DELETE /resources
Content-Type: application/json

{"ids": [5, 6, 7]}
C
DELETE /resources
Content-Type: application/json

[5, 6, 7]
D
DELETE /resources/5,6,7
Content-Type: application/json

{}
Attempts:
2 left
💡 Hint

Consider the correct use of HTTP method, URL, headers, and body format for batch delete.