Middle
List the REST API methods on the backend required to implement task management system scenarios. For each method, suggest a valid URI according to REST architectural style.
sobes.tech AI
Answer from AI
The main REST API methods and corresponding URIs for a task management system might be as follows:
- GET /tasks — retrieve a list of all tasks.
- GET /tasks/{id} — get details of a specific task by its identifier.
- POST /tasks — create a new task.
- PUT /tasks/{id} — fully update a task with the specified id.
- PATCH /tasks/{id} — partially update a task.
- DELETE /tasks/{id} — delete a task.
If the system has users and tasks are associated with them, you can add:
- GET /users/{userId}/tasks — get tasks for a specific user.
Example of a request to create a task:
POST /tasks
Content-Type: application/json
{
"title": "Prepare report",
"description": "Prepare the sales report for the month",
"dueDate": "2024-07-01"
}
This approach aligns with REST principles, where resources are represented as URIs, and HTTP methods define actions on them.