Middle
For endpoint POST /api/tasks (create task): 1) What input parameters are required? 2) What service parameters are needed for authentication and authorization? 3) Provide an example of a valid JSON request with an array of tag_ids. 4) What HTTP response statuses would you use?
sobes.tech AI
Answer from AI
- Input parameters for POST /api/tasks:
title(string) — task name, required.description(string) — task description, optional.due_date(string, ISO 8601 format) — completion date, optional.priority(string or int) — task priority, optional.tag_ids(array of int) — identifiers of tags associated with the task, optional.
- Service parameters for authentication and authorization:
- Header
Authorization: Bearer <token>— user access token. - Possibly additional headers or cookies if a session is used.
- Example of a valid JSON request:
{
"title": "Create report",
"description": "Prepare a sales report for the month",
"due_date": "2024-07-01T18:00:00Z",
"priority": "high",
"tag_ids": [12, 34, 56]
}
- HTTP response statuses:
201 Created— task successfully created.400 Bad Request— invalid format or missing required fields.401 Unauthorized— missing or invalid authentication token.403 Forbidden— user does not have permission to create a task.500 Internal Server Error— internal server error.
This set of statuses covers the main interaction scenarios with the API.