We have tried to create a post in wordpress using postman, cant able to create one since we have received error as you are not allowed to do this action
Eventhough i entered the admin login, it gives the same error !!!!
This is the exact error message ,
{
"code": "rest_cannot_create",
"message": "Sorry, you are not allowed to create posts as this user.",
"data": {
"status": 401
}
}
I have tried using this URL in the postman (post) method http://localhost/wordpress/wp-json/wp/v2/posts
And in the authorization entered the admin credentials of my application.
Any alternative solutions are also appreciable …..Thank You!!!
2
Answers
you can use this code
There is a plugin available in WordPress for Basic Authentication configuration, that will help. It’s free for Basic Authentication you can search the plugin name REST API Authentication in your site and configure the Basic Authentication setup. And you can create the post using the WordPress endpoints.
https://developer.wordpress.org/rest-api/reference/posts/
Note : It will be safer to create a new user by having Author role. So that use can access the site only for creating the posts.
Here I’m adding the plugin documentation for reference
https://plugins.miniorange.com/wordpress-rest-api-basic-authentication-method