Update Post
Update an existing post.
Endpoint
PUT /api/Post/{postId}
Authentication: Required (must be post author)
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| postId | GUID | Yes | Post ID |
Request Body
JSON or multipart/form-data with optional caption and visibility:
{
"caption": "Updated post content",
"visibility": "Friends"
}
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| caption | string | No | Updated post caption |
| visibility | string | No | Public, Friends, OnlyMe |
Response
Success (200 OK)
{
"success": true,
"data": {
"id": "post-id",
"content": "Updated post content",
"updatedAt": "2024-01-01T01:00:00Z"
}
}
Error (403 Forbidden)
{
"success": false,
"error": {
"code": "FORBIDDEN",
"message": "You can only update your own posts"
}
}
Example
const response = await fetch(`http://localhost:5000/api/Post/${postId}`, {
method: 'PUT',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
content: 'Updated post content',
privacy: 'friends'
})
});
const data = await response.json();
Limitations
- Only the post author can update the post
- Media cannot be updated (delete and recreate)
- Update history is tracked