【问题标题】:How to upload a file to a slack channel using a bot如何使用机器人将文件上传到松弛通道
【发布时间】:2019-03-12 22:40:04
【问题描述】:

我有一个 slack 机器人,以 xoxb 开头的令牌用于将文件上传到频道。

我正在使用以下格式

curl -F token="${SLACK_TOKEN}" -F file=e2e.sh -F channel="${SLACK_CHANNEL}" -F  as_user=true https://slack.com/api/files.upload

这会抛出

{"ok":false,"error":"no_file_data"}

【问题讨论】:

    标签: slack slack-api


    【解决方案1】:

    您在 file=e2e.sh 参数中缺少 @ 以让 curl 知道您要传输文件。以下应该可以解决问题:

    curl \
      -F token="${SLACK_TOKEN}" \
      -F file=@e2e.sh \
      -F channel="${SLACK_CHANNEL}" \
      -F as_user=true \
      https://slack.com/api/files.upload
    

    附言将长卷发分成多行可以帮助您更清楚地看到事物;)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-12-10
      • 1970-01-01
      • 1970-01-01
      • 2022-06-24
      • 1970-01-01
      • 2017-03-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多