不和谐的webhook无法发送空消息 [英] discord webhook can not send empty message

查看:172
本文介绍了不和谐的webhook无法发送空消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为不和谐的webhooks编写了这个小的PoC,但我收到了无法发送空字符串的错误消息。我试图用Google搜索,但找不到文档或答案

I have written this small PoC for discord webhooks and i am getting error that Can not send empty string. I tried to google but couldn't find a documentation or an answer

这是我的代码

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)


推荐答案

我来晚了,但最近遇到了这个问题,因为尚未得到答复,所以我认为我已记录了解决问题的方法。

I'm late, but I came across this issue recently, and seeing as it has not been answered yet, I thought I document my solution to the problem.

在很大程度上,这主要是由于有效载荷的结构错误。

For the most part, it is largely due to the structure of the payload being wrong.

https://birdie0.github.io/discord-webhooks-guide/discord_webhook.html 提供了一个示例工作结构中的e。 https://discordapp.com/developers/docs/resources/channel#create- message 是官方文档。

https://birdie0.github.io/discord-webhooks-guide/discord_webhook.html provides an example of a working structure. https://discordapp.com/developers/docs/resources/channel#create-message is the official documentation.

我还能够使用以下方法获得最低测试用例: { content:测试}

I was also able to get a minimum test case working using: {"content": "Test"}.

如果在此之后仍然失败并出现相同的错误,则可能的原因是:

If it still fails after that with the same error, the likely causes are:


  • 如果使用curl,请检查以确保没有意外的转义/反斜杠 \

  • 如果对字段使用嵌入,请确保没有空值

如有疑问,请确保所有值都已填充,而不是 。通过反复试验/取消过程,您可以准确地找出导致问题的键值对,因此,我建议在将curl变成完整程序之前,通过curl使用webhook。

When in doubt, ensure all values are populated, and not "". Through trial-and-error / the process of cancellation, you can figure out exactly what key-value pair is causing an issue, so I suggest playing with the webhook via curl before turning it into a full program.

这篇关于不和谐的webhook无法发送空消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆