We need an endpoint which will accept a POST request with json body, validate the request and create a new post in db. author_id field should be filled by user id from JWT token. We should return 400 if request isn't valid. We should return 401 if JWT token isn't provided. We should return 403 if user from JWT token was not found in database.
Request example
POST /topics/42/posts
{
"body": "Some post body" # required non-blank string field
}
We need an endpoint which will accept a POST request with json body, validate the request and create a new post in db.
author_id
field should be filled by user id from JWT token. We should return 400 if request isn't valid. We should return 401 if JWT token isn't provided. We should return 403 if user from JWT token was not found in database.Request example
Response example
So in the scope of this task we need to create endpoint which will create a new post and return info about it.