Skip to main content

Update Post

Update an existing post.

Endpoint

PUT /api/Post/{postId}

Authentication: Required (must be post author)

Path Parameters

ParameterTypeRequiredDescription
postIdGUIDYesPost ID

Request Body

JSON or multipart/form-data with optional caption and visibility:

{
"caption": "Updated post content",
"visibility": "Friends"
}

Parameters

ParameterTypeRequiredDescription
captionstringNoUpdated post caption
visibilitystringNoPublic, 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

Next Steps