I'm trying to post a comment via the WP REST API. Here is my request:
axios({
method: 'post',
url: `${WP_API_ENDPOINT}/comments`,
headers: {'X-WP-Nonce': wpRestSettings.nonce},
data: {
"post": 8911,
"author_name": "Mr. Author",
"author_email": "[email protected]",
"content": "A new comment."
}
})
I've also tried adding the nonce in the data instead under the value _wpnonce
per the spec.
I saw one answer suggest adding this filter: add_filter( 'filter_rest_allow_anonymous_comments', '__return_true' );
I keep getting the same 401 response. If I post using basic auth, it works, nonces aren't.