Open Pythonian opened 2 months ago
{
"status_code": 200
"message": "Blog post updated successfully",
"data": {
"id": "7d1f89c2-3c24-7c3f-a8e5-9a8a3e6d2f7b",
"title": "Updated Title",
"content": "Updated content",
"author_id": "a7f6e0c1-52e5-4d30-8b27-f2be4d4d1c77"
}
}
I think the response body should incorporate some of the structure above.
{
"message": "Blog successfully updated",
"id": "int",
"title": "string",
"excerpt": "string",
"content": "string",
"author": "string",
"updated_at": "datetime",
}
Description
Develop an endpoint to handle requests to update an existing blog post. This endpoint will validate the input data and update the blog post securely in the database. This endpoint should be accessible only to super admins. If the blog post is updated successfully, it will be returned to the client with a
200 OK
status. If an error occurs, an appropriate error status will be returned.Acceptance Criteria
200 OK
status code and the updated blog post data when the blog post is updated successfully.Purpose
Provide the necessary backend services to allow super admin to edit and update their previously published blog posts.
Requirements
409 Conflict
status code.PATCH
method.Expected Outcome
Endpoints
[PATCH] /api/v1/blogs/:id
Description: Updates an existing blog post.
Path Parameters:
id
: The ID of the blog post to update.Request Body:
title
: The title of the blog post.content
: The content of the blog post.updated_at
: The updated date of the blog post.Success Response:
200 OK
Error Response:
500 Internal Server Error
Unauthorized Response:
403 Forbidden
Not Found Response:
404 Not Found
Conflict Response:
409 Conflict
Bad Request Response:
400 Bad Request
Testing
Test Scenarios
Successful Update of Blog Post
200 OK
status code.Unauthorized Access
403 Forbidden
status code and an appropriate error message.Conflict Error
409 Conflict
status code and an appropriate error message.Internal Server Error
500 Internal Server Error
status code and an appropriate error message.Blog Post Not Found
404 Not Found
status code and an appropriate error message.Invalid Data
400 Bad Request
status code and an appropriate error message.