Em *_* Ae 5 webhooks python-3.x discord
我已经为不和谐的 webhooks 编写了这个小 PoC,但收到Can not send empty string 的错误。我尝试谷歌但找不到文档或答案
这是我的代码
import requests
discord_webhook_url = 'https://discordapp.com/api/webhooks/xxxxxxxxxxxxxxxxxx/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
data = {'status': 'success'}
headers = {'Content-Type': 'application/json'}
res = requests.post(discord_webhook_url, data=data, headers=headers)
print(res.content)
Run Code Online (Sandbox Code Playgroud)
我迟到了,但我最近遇到了这个问题,由于它还没有得到解答,我想我记录了我对该问题的解决方案。
在大多数情况下,这很大程度上是由于有效负载的结构错误造成的。
https://birdie0.github.io/discord-webhooks-guide/discord_webhook.html提供了工作结构的示例。https://discordapp.com/developers/docs/resources/channel#create-message是官方文档。
我还能够使用以下方法获得最小测试用例{"content": "Test"}:
如果之后仍然失败并出现相同的错误,可能的原因是:
\如有疑问,请确保填充所有值,而不是""。通过试错/取消过程,您可以准确地找出导致问题的键值对,因此我建议在将其变成完整程序之前通过curl使用webhook。