I’ve tried everything. Can’t change user role via Rest API

[ad_1]

I’ve been trying to change user roles on my site for days using a POST HTTP request using the endpoint (**https://example.com/wp-json/wp/v2/users/{USER\_ID})**. I put the correct user ID in the URL and use JSON to change the role (“roles”: \[“editor”\]). I use basic auth using my wordpress username and password. Every time I get this error.

{
“code”: “rest\_user\_cannot\_view”,
“message”: “Sorry, you are not allowed to list users.”,
“data”: {
“status”: 401
}
}

I’m using the admin account for my site which has all capabilities enabled. My site uses shared hosting with dreamhost. I don’t know what it could be. Thank you for the help.

[ad_2]
1 Comment
  1. Usually REST will take a PATCH method (sometimes PUT) for updating.

    POST is usually reserved for creating new items…

    Not sure on this specific case, but try a PATCH request

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer