Search code examples
jsonwordpresswordpress-rest-api

How to Create a comment using WP Rest API v2?


I'm trying to create a new comment via the WP Rest APi v2 using a POST request to the following url:

https://www.turboweb.online/wp-json/wp/v2/comments?author_email=admin@admin.com&author_name=alex bhati&content=nice post&post=4002

But, this is the response I'm getting every time:

{
    "code": "rest_forbidden_param",
    "message": "Query parameter not permitted: author_email",
    "data": {
        "status": 401
    }
}

Solution

  • The author_email field requires authorization in order to be added, maybe this answer can help: WP Rest API not allowing to post anonymous comments through a Laravel request