当我通过Postman发送PUT请求时,一切都还好,但是当我将代码从Postman复制到Python时,我会得到这个:
代码:{“代码”:50035,“ errors”:{“ _ERRORS”:[{“ code”:“ content_type_invalid”,“ message”:“预期” content-type“成为{application/json'}之一。
url = "https://discord.com/api/v9/guilds/860859559908474900/premium/subscriptions"
payload={'user_premium_guild_subscription_slot_ids': '853228009795223572'}
files=[
]
headers = {
'authorization': 'here token',
'Cookie': '__dcfduid=c5cbabf10a8344558c8c4b90a6e306e2'
}
response = requests.request("PUT", url, headers=headers, data=payload, files=files)
print(response.text)
如果我将'content-type'添加到标题中'application/json',我会知道:
{“消息”:“ 400:坏请求”,“代码”:0}
json=
而不是
data=
或添加带有值的标题
Content-Type
当服务器告诉您时。还检查
application/json
标题,主要是一个前缀,该前缀提到了要使用的词
Authorization
确保实际上允许
Authorization: Basic base64-encoded(user:pass)
Authorization: Bearer token
Authorization: Token token
参数被API空,如果没有,请尝试将其删除。
然后您提供的cookie。某些cookie往往是动态的,就像请求之间的价值变化一样。然后尝试建立会话并在其中进行登录部分:
files