0
0
Rest APIprogramming~20 mins

Batch create endpoint design in Rest API - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Batch Create Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:00remaining
Best HTTP method for batch create

Which HTTP method is most appropriate for a batch create endpoint in a REST API?

AGET
BPUT
CPOST
DDELETE
Attempts:
2 left
💡 Hint

Think about which method is used to create new resources.

Predict Output
intermediate
1:00remaining
Response status code for successful batch create

What is the correct HTTP status code returned after successfully creating multiple resources in a batch?

A201 Created
B200 OK
C204 No Content
D400 Bad Request
Attempts:
2 left
💡 Hint

Consider the status code that indicates resource creation.

Predict Output
advanced
1:30remaining
Batch create response body format

Given a batch create request that creates three new users, which response body best follows REST API best practices?

Rest API
Request body:
[
  {"name": "Alice"},
  {"name": "Bob"},
  {"name": "Charlie"}
]
A{"message": "Users created successfully"}
B{"created": 3}
C["/users/1", "/users/2", "/users/3"]
D[{"id": 1, "name": "Alice"}, {"id": 2, "name": "Bob"}, {"id": 3, "name": "Charlie"}]
Attempts:
2 left
💡 Hint

Think about returning the created resources with their new IDs.

🧠 Conceptual
advanced
2:00remaining
Handling partial failures in batch create

In a batch create endpoint, if some items fail validation but others succeed, what is the best practice for the response?

AReturn 400 Bad Request with details about all failed items and no created items
BReturn 207 Multi-Status with details about success and failure for each item
CReturn 201 Created with only the successfully created items in the response body
DReturn 500 Internal Server Error because partial success is not allowed
Attempts:
2 left
💡 Hint

Think about how to communicate mixed results clearly.

🚀 Application
expert
2:30remaining
Designing idempotent batch create endpoint

You want to design a batch create endpoint that is idempotent (safe to retry without creating duplicates). Which approach is best?

ARequire clients to send a unique client-generated ID for each item and reject duplicates
BAllow duplicates and rely on server to filter them after creation
CUse POST without any client IDs and accept duplicates on retries
DUse GET method to create resources so retries do not duplicate
Attempts:
2 left
💡 Hint

Think about how to identify repeated requests uniquely.