Go REST
N

POST comments API asking for a field that is already in the body

Nissan Boy about 3 years ago 4024 views 2 replies

Request I'm sending:
curl --location --request POST 'https://gorest.co.in/public/v2/posts/457749/comments' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer 9d....080' \
--data-raw '{
post: 5375,
name: NameNew,
email: Waino.Dickinson92@gmail.com,
body: Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
}'

Response with code 422:
[
{
field: post,
message: must exist
}
]

Maybe I'm missing something? Any help would be nice. Also the post id is correct I've check that with GET request

2 replies
Z
zeevy about 3 years ago

Try post_id insted of post.

Z
zeevy about 3 years ago

You don't need to pass post I'd as you are using nested url, just remove post and try, the post I'd in the url 457749 must exist

Your reply

Markdown supported