TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/tutosrive/fastapi-CRUD-MongoDB/llms.txt
Use this file to discover all available pages before exploring further.
PUT /tasks/{id} endpoint performs a partial update on an existing task document. The request body is validated against the TaskUpdate model, where every field is Optional. Before the update is sent to MongoDB, the task_update_entity() helper strips any None-valued keys from the dict so that only the explicitly provided fields are passed to MongoDB’s $set operator. The endpoint then re-fetches the document and returns the full updated task object.
PUT /tasks/{id}
Path Parameters
MongoDB ObjectId expressed as a 24-character hex string (e.g.
64a1b2c3d4e5f6789abcde01) identifying the task to update.Request Body
All fields are optional. Include only the fields you want to change.New title for the task.
New description for the task.
Updated completion status of the task.
Updated user identifier associated with the task.
Example Request — Partial Update
Mark a task as completed without touching any other fields:Example Request Body — Partial
Example Request Body — Full
Example Response
Response Fields
MongoDB ObjectId serialised as a 24-character hex string.
The task title after the update.
The task description after the update.
The completion status after the update.
The user identifier after the update.
Unlike a typical full-replacement PUT, this endpoint uses the
TaskUpdate model where all fields are Optional. The task_update_entity() function iterates over the dict and removes any key whose value is None, so only fields that are explicitly provided (and non-None) are forwarded to MongoDB’s $set operator. Fields whose value is None are stripped and left unchanged in MongoDB.Error Responses
| Status | Detail | Cause |
|---|---|---|
404 Not Found | "Task Not Found!" | No task document exists in MongoDB with the provided id. |
422 Unprocessable Entity | Validation error details | A provided field has an incompatible type (e.g. passing a string for completed). |
500 Internal Server Error | Server error message | Database connection failure or malformed ObjectId string. |