松弛 API conversations.replies internal_error

Slack API conversations.replies internal_error

当有人使用 python slack api 将消息发布到私人 slack 频道时,我试图获得线程回复,但我不断收到以下错误:

{"ok":false,"error":"internal_error","warning":"missing_charset",
 "response_metadata":{"warnings":["missing_charset"]}}

我的用户令牌的范围是:channels:historygroups:historychat:write

这是我的代码:

slack_client = WebClient(token='xoxp-xxxx-xxxx-xxxx-xxxx')

resp = slack_client.api_call(api_method="conversations.replies",
                             json={"channel": 'xxxx',
                                   "ts": received_data['event']['thread_ts'], 
                                   "token": 'xoxp-xxxx-xxxx-xxxx-xxxx'})

我使用 curl 得到同样的错误:

curl -X POST -H 'Authorization: Bearer xoxp-xxxx-xxxx-xxxx' -H "Content-type: application/json"
--data '{"token": "xoxp-xxxx-xxxx-xxxx-xxxx","ts":"1595895414.009700", "channel": "xxxx"}'
https://slack.com/api/conversations.replies

我认为你必须使用 GET 方法

你可以在参数中添加 http_verb="GET"api_call 方法

还有一个conversations_replies包装这个调用的方法

谢谢!这是我的代码最终的样子:

slack_client = WebClient(token='xoxp-xxxx-xxxx-xxxx-xxxx')

resp = slack_client.api_call(api_method="conversations.replies",
                             params={"channel": 'xxxx',
                                   "ts": received_data['event']['thread_ts'], 
                                   "token": 'xoxp-xxxx-xxxx-xxxx-xxxx'},
                             http_verb="GET")