cannot comment on post through API
-
I'm hitting the following URL with the request body below:
{{baseUrl}}/?rest_route=/wp/v2/comments
{
"author_name" : "Postman",
"date" : "2024-08-21T18:46:25",
"parent" : 0,
"author_user_agent" : "author_user_agent",
"author" : 0,
"author_ip" : "35.179.22.245",
"content" : "This is an api-generated comment",
"author_url" : "https://mysite.com",
"post" : 17,
"meta" : {},
"author_email" : "[email protected]",
"date_gmt" : "2024-08-21T18:46:25",
"status" : "publish"
}
The error I get is:
{
"code": "rest_comment_invalid_post_id",
"message": "Sorry, you are not allowed to create this comment without a post.",
"data": {
"status": 403
}
}
But the post exists. Here is my API call:
{{baseUrl}}/?rest_route=/wp/v2/posts/17
{
"id": 17,
"date": "2024-08-22T18:44:15",
"date_gmt": "2024-08-22T18:44:15",
"guid": {
"rendered": "https://myurl.com/?p=17"
},
"modified": "2024-08-22T18:44:15",
"modified_gmt": "2024-08-22T18:44:15",
"slug": "update-3",
"status": "publish",
"type": "post",
"link": "https://myurl.com/?p=17",
"title": {
"rendered": "java_generated"
},
"content": {
"rendered": "<p>this is a post using java</p>\n",
"protected": false
},
"excerpt": {
"rendered": "<p>java</p>\n",
"protected": false
},
"author": 1,
"featured_media": 0,
"comment_status": "open",
"ping_status": "open",
"sticky": false,
"template": "",
"format": "standard",
"meta": {
"footnotes": ""
},
"categories": [],
"tags": [],
"class_list": [
"post-17",
"post",
"type-post",
"status-publish",
"format-standard",
"hentry"
],
"_links": {
"self": [
{
"href": "https://myurl.com/index.php?rest_route=/wp/v2/posts/17"
}
],
"collection": [
{
"href": "https://myurl.com/index.php?rest_route=/wp/v2/posts"
}
],
"about": [
{
"href": "https://myurl.com/index.php?rest_route=/wp/v2/types/post"
}
],
"author": [
{
"embeddable": true,
"href": "https://myurl.com/index.php?rest_route=/wp/v2/users/1"
}
],
"replies": [
{
"embeddable": true,
"href": "https://myurl.com/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=17"
}
],
"version-history": [
{
"count": 0,
"href": "https://myurl.com/index.php?rest_route=/wp/v2/posts/17/revisions"
}
],
"wp:attachment": [
{
"href": "https://myurl.com/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=17"
}
],
"wp:term": [
{
"taxonomy": "category",
"embeddable": true,
"href": "https://myurl.com/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=17"
},
{
"taxonomy": "post_tag",
"embeddable": true,
"href": "https://myurl.com/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=17"
}
],
"curies": [
{
"name": "wp",
"href": "https://api.w.org/{rel}",
"templated": true
}
]
}
}
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- You must be logged in to reply to this topic.