为什么此请求返回400? (Python3请求)

时间:2019-02-24 10:34:56

标签: python http python-requests discord http-status-codes

尽管在发送相同的样式的相似请求似乎可以在同一站点的其他部分正常工作,我仍然无法发送发布请求,因为它返回错误400而不是预期的204。 >

以下是Google chrome接受请求的示例:

Request URL: https://discordapp.com/api/v6/users/@me/relationships
Request Method: POST
Status Code: 204 
Remote Address: IP
Referrer Policy: no-referrer-when-downgrade
access-control-allow-credentials: true
access-control-allow-headers: Content-Type, Authorization, X-Track, X-Super-Properties, X-Context-Properties, X-Failed-Requests, X-Fingerprint, X-RPC-Proxy, X-Debug-Options, If-None-Match
access-control-allow-methods: POST, GET, PUT, PATCH, DELETE
access-control-allow-origin: https://discordapp.com
alt-svc: clear
cf-ray: 4ae0db43cf473464-LHR
date: Sun, 24 Feb 2019 09:20:28 GMT
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
server: cloudflare
status: 204
strict-transport-security: max-age=31536000; includeSubDomains
via: 1.1 google
:authority: discordapp.com
:method: POST
:path: /api/v6/users/@me/relationships
:scheme: https
accept: */*
accept-encoding: gzip, deflate, br
accept-language: en-GB
authorization: USER TOKEN
content-length: 46
content-type: application/json
cookie: __cfduid=dda2a2e2ad66d52129871a4410708b3941545858349; _ga=GA1.2.393621366.1545937419; locale=en-US; _gid=GA1.2.803863711.1550442266; _gat_UA-53577205-2=1
dnt: 1
origin: https://discordapp.com
referer: https://discordapp.com/channels/@me
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
x-context-properties: eyJsb2NhdGlvbiI6IkFkZCBGcmllbmQifQ==
x-fingerprint: 547382949931384833.wx3cZudz6zpRaSSwwn2N0xyAmAo
{username: "USERNAME", discriminator: 999}
discriminator: 9999
username: "USERNAME"

这是我尝试发送请求的代码:

headers={"authorization": "TOKEN HERE"}
params={"username": "USERNAME", "discriminator": 9999}

r = requests.post("https://canary.discordapp.com/api/v6/users/@me/relationships",headers=headers,params=params)
print(r.status_code)

我以前有一个类似的结构请求,要求删除正常工作的聊天消息:

requests.delete("http://canary.discordapp.com/api/v6/channels/" + CHANNEL ID + "/messages/" + MESSAGE ID, headers={"authorization": "TOKEN"})

0 个答案:

没有答案