我已经通过wordpress api创建了一个用户,然后在注册后,我将用户的用户名和密码保存到会话存储中,最后尝试编辑用户的配置文件。这是我的post请求数据
POST /wp-json/wp/v2/users?context=edit HTTP/1.1
Host: something.com
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\\"}}"
}
现在,有了这个请求,我得到了“{”code“:“rest\\u cannot\\u create\\u user”,“message”:“抱歉,不允许您创建新用户。”,“数据”:{“状态”:403}}
答复是:
{
"code": "rest_cannot_create_user",
"message": "Sorry, you are not allowed to create new users.",
"data": {
"status": 403
}
}
现在,如果我尝试通过postman与该用户创建帖子,它会正常工作。我做错了什么?