首页 > 解决方案 > 错误的请求 | 不和谐 api v8

问题描述

代码:

headers = {"authorization": f"{config['token']}","Content-Type":"application/json"}
data1 = {"recipients":[f"{member.id}"]}
r1 = requests.request("POST", f"https://discord.com/api/v8/users/{ctx.author.id}/channels", headers=headers, data=data1)

我收到错误的请求错误,代码:0

这些值中的每一个都像 member.id 一样存在。没有 NoneType

标签: pythonapidiscord

解决方案


实际的授权标头具有以下格式:

Authorization: Bot TOKEN

因此,您需要将标题更改为

headers = {"Authorization": f"Bot {config['token']}", ...}

推荐阅读