node-wpapi
node-wpapi copied to clipboard
Error code "rest_cannot_read", status code 401
Hi,
I'm getting an error when trying to retrieve revisions to a post
Here's how I perform the basic auth:
const wp = new WPAPI({
endpoint: 'https://www.my-url.com/wp-json',
username: 'username',
password: 'password',
auth: true,
})
And my request looks like this:
wp
.posts()
.id(postId)
.revisions()
.then((result) => {
console.log ('result', result)
return result
})
Error
{
code: 'rest_cannot_read',
message: 'No permission to view revisions to this post.'
data: {status: 401}
}
In wordpress I'm using this plugin https://github.com/WP-API/Basic-Auth
Reference http://wp-api.org/node-wpapi/authentication/#basic-authentication
Am I doing something wrong? Can someone help me please
Have you checked your permissions to view posts? Is this your post?
@MartinSchere I have the role as administrator, I can see the post, but this post is not mine.