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]
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