admin管理员组文章数量:1130349
I have created an user via wordpress api, then after registration, I save user's username and password into the sessionStorage, and then, finaly, try to edit user's profile. Here's my post request data
POST /wp-json/wp/v2/users?context=edit HTTP/1.1
Host: something
Connection: keep-alive
Content-Length: 292
Accept: application/json, text/plain, */*
Origin: http://localhost:8100
Authorization: Bearer ********************************************************************************************************
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36
Content-Type: application/json;charset=UTF-8
Referer: http://localhost:8100/
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
POST Body
"postData": {
"mimeType": "application/json;charset=UTF-8",
"text": "{\"first_name\":\"Foo\",\"last_name\":\"Bar\",\"city\":\"Belgrade\",\"zip\":11000,\"address\":\"Foobar 7\",\"email\":\"[email protected]\",\"username\":\"foobar\",\"name\":\"Foo Bar\",\"nickname\":\"Foo Bar\",\"password\":\"myexamplepass\",\"context\":\"edit\",\"meta\":{\"city\":\"Belgrade\",\"zip\":11000,\"address\":\"FooBar 17\"}}"
}
Now, with that request, I get {"code":"rest_cannot_create_user","message":"Sorry, you are not allowed to create new users.","data":{"status":403}}
Response is:
{
"code": "rest_cannot_create_user",
"message": "Sorry, you are not allowed to create new users.",
"data": {
"status": 403
}
}
Now, if I try to create a post with that very user, via postman, it works properly. What am I doing wrong here?
I have created an user via wordpress api, then after registration, I save user's username and password into the sessionStorage, and then, finaly, try to edit user's profile. Here's my post request data
POST /wp-json/wp/v2/users?context=edit HTTP/1.1
Host: something
Connection: keep-alive
Content-Length: 292
Accept: application/json, text/plain, */*
Origin: http://localhost:8100
Authorization: Bearer ********************************************************************************************************
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36
Content-Type: application/json;charset=UTF-8
Referer: http://localhost:8100/
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
POST Body
"postData": {
"mimeType": "application/json;charset=UTF-8",
"text": "{\"first_name\":\"Foo\",\"last_name\":\"Bar\",\"city\":\"Belgrade\",\"zip\":11000,\"address\":\"Foobar 7\",\"email\":\"[email protected]\",\"username\":\"foobar\",\"name\":\"Foo Bar\",\"nickname\":\"Foo Bar\",\"password\":\"myexamplepass\",\"context\":\"edit\",\"meta\":{\"city\":\"Belgrade\",\"zip\":11000,\"address\":\"FooBar 17\"}}"
}
Now, with that request, I get {"code":"rest_cannot_create_user","message":"Sorry, you are not allowed to create new users.","data":{"status":403}}
Response is:
{
"code": "rest_cannot_create_user",
"message": "Sorry, you are not allowed to create new users.",
"data": {
"status": 403
}
}
Now, if I try to create a post with that very user, via postman, it works properly. What am I doing wrong here?
Share Improve this question asked May 14, 2018 at 23:55 errorouserrorous 1691 silver badge9 bronze badges1 Answer
Reset to default 2My REST URL was wrong - I didn't add the userid to the url. Proper REST URL should be: /wp-json/wp/v2/users/30/ where 30 should be changed with user's id.
I have created an user via wordpress api, then after registration, I save user's username and password into the sessionStorage, and then, finaly, try to edit user's profile. Here's my post request data
POST /wp-json/wp/v2/users?context=edit HTTP/1.1
Host: something
Connection: keep-alive
Content-Length: 292
Accept: application/json, text/plain, */*
Origin: http://localhost:8100
Authorization: Bearer ********************************************************************************************************
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36
Content-Type: application/json;charset=UTF-8
Referer: http://localhost:8100/
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
POST Body
"postData": {
"mimeType": "application/json;charset=UTF-8",
"text": "{\"first_name\":\"Foo\",\"last_name\":\"Bar\",\"city\":\"Belgrade\",\"zip\":11000,\"address\":\"Foobar 7\",\"email\":\"[email protected]\",\"username\":\"foobar\",\"name\":\"Foo Bar\",\"nickname\":\"Foo Bar\",\"password\":\"myexamplepass\",\"context\":\"edit\",\"meta\":{\"city\":\"Belgrade\",\"zip\":11000,\"address\":\"FooBar 17\"}}"
}
Now, with that request, I get {"code":"rest_cannot_create_user","message":"Sorry, you are not allowed to create new users.","data":{"status":403}}
Response is:
{
"code": "rest_cannot_create_user",
"message": "Sorry, you are not allowed to create new users.",
"data": {
"status": 403
}
}
Now, if I try to create a post with that very user, via postman, it works properly. What am I doing wrong here?
I have created an user via wordpress api, then after registration, I save user's username and password into the sessionStorage, and then, finaly, try to edit user's profile. Here's my post request data
POST /wp-json/wp/v2/users?context=edit HTTP/1.1
Host: something
Connection: keep-alive
Content-Length: 292
Accept: application/json, text/plain, */*
Origin: http://localhost:8100
Authorization: Bearer ********************************************************************************************************
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36
Content-Type: application/json;charset=UTF-8
Referer: http://localhost:8100/
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
POST Body
"postData": {
"mimeType": "application/json;charset=UTF-8",
"text": "{\"first_name\":\"Foo\",\"last_name\":\"Bar\",\"city\":\"Belgrade\",\"zip\":11000,\"address\":\"Foobar 7\",\"email\":\"[email protected]\",\"username\":\"foobar\",\"name\":\"Foo Bar\",\"nickname\":\"Foo Bar\",\"password\":\"myexamplepass\",\"context\":\"edit\",\"meta\":{\"city\":\"Belgrade\",\"zip\":11000,\"address\":\"FooBar 17\"}}"
}
Now, with that request, I get {"code":"rest_cannot_create_user","message":"Sorry, you are not allowed to create new users.","data":{"status":403}}
Response is:
{
"code": "rest_cannot_create_user",
"message": "Sorry, you are not allowed to create new users.",
"data": {
"status": 403
}
}
Now, if I try to create a post with that very user, via postman, it works properly. What am I doing wrong here?
Share Improve this question asked May 14, 2018 at 23:55 errorouserrorous 1691 silver badge9 bronze badges1 Answer
Reset to default 2My REST URL was wrong - I didn't add the userid to the url. Proper REST URL should be: /wp-json/wp/v2/users/30/ where 30 should be changed with user's id.
本文标签: WordPress REST Api update user
版权声明:本文标题:WordPress REST Api: update user 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749057606a2309596.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论