Update Comment
Update an existing comment. The backend Comment controller exposes create, reply, get, delete, and comment reactions; update may be implemented elsewhere or not exposed. Use api/Comment for all comment operations.
Endpoint (if supported)
PUT /api/Comment/{commentId}
Authentication: Required (must be comment author)
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| commentId | string | Yes | Comment ID |
Request Body
{
"content": "Updated comment text"
}
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| content | string | Yes | Updated comment text |
Response
Success (200 OK)
{
"success": true,
"data": {
"id": "comment-id",
"content": "Updated comment text",
"updatedAt": "2024-01-01T01:00:00Z"
}
}
Error (403 Forbidden)
{
"success": false,
"error": {
"code": "FORBIDDEN",
"message": "You can only update your own comments"
}
}
Example
const response = await fetch(`http://localhost:5000/api/Comment/${commentId}`, {
method: 'PUT',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
content: 'Updated comment text'
})
});
const data = await response.json();
Limitations
- Only the comment author can update the comment
- Edit history is tracked
- Comments can be edited within 24 hours of creation