我正在尝试使用Slack的chat.postMessage API调用发送消息.我在HTTP GET中编码测试消息没有问题,但我试图在HTTP POST请求中使用JSON实现相同的结果.
我一直在curl和Postman一起测试,但Slack似乎根本没有承认我的请求体.
{
"ok": false,
"error": "not_authed"
}
Run Code Online (Sandbox Code Playgroud)
在curl,我的请求编码如下:
curl -H "Content-type: application/json" -X POST -d '{"token":"my-token-here","channel":"#channel-name-or-id","text":"Text here.","username":"otherusername"}'
Run Code Online (Sandbox Code Playgroud)
在邮递员中,这是原始身体:
{
"token":"my-token-here",
"channel":"#channel-name-or-id",
"text":"Text here.",
"username":"otherusername"
}
Run Code Online (Sandbox Code Playgroud)
我之前没有做过这样的事情,所以我不确定我是否遗漏了一些东西.谢谢!