Iam正在尝试使用rest api admin api帐户删除订阅服务器用户。然而,api似乎需要指定重新分配用户id,但我不想重新分配。
Iam使用python请求模块,我发出一个基本的删除请求,如下所示:
import base64
import requests
import json
from Load_Credentials import user,password
userurl=\'https://mywebsite.com/wp-json/wp/v2/users\'
credentials = user + \':\' + password
token = base64.b64encode(credentials.encode())
header = {\'Authorization\': \'Basic \' + token.decode(\'utf-8\'),\'Content-Type\': \'application/json\',\'User-Agent\': \'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36\'}
userid=139
deleteurl=\'https://mywebsite.com/wp-json/wp/v2/users/139?force=True\'
response = requests.delete(deleteurl, headers=header)
print(response.json())
这是我得到的回应:
\'code\': \'rest_missing_callback_param\', \'message\': \'Missing parameter(s): reassign\', \'data\': {\'status\': 400, \'params\': [\'reassign\']}}
我知道请求需要重新分配参数,但是,我不想重新分配,我想删除而不重新分配。我尝试了重新分配=false,但也没有成功:
deleteurl=https://myywebsite.com/wp-json/wp/v2/users/139?reassign=false?force=True
以下是回复:
{\'code\': \'rest_invalid_param\', \'message\': \'Invalid parameter(s): reassign\', \'data\': {\'status\': 400, \'params\': {\'reassign\': \'Invalid user parameter(s).\'}, \'details\': {\'reassign\': {\'code\': \'rest_invalid_param\', \'message\': \'Invalid user parameter(s).\', \'data\': {\'status\': 400}}}}}
有什么建议吗?