gpt4 book ai didi

slack-api - 为什么 Slack 的 files.list 端点返回一个空文件数组?

转载 作者:行者123 更新时间:2023-12-05 04:54:46 25 4
gpt4 key购买 nike

我想使用 Slack API 从我的工作空间中删除旧文件,因为我们上传新文件的空间不足。

我注册了一个应用程序,将其安装在目标工作区上,授予应用程序 files:readfiles:write 权限,然后为具有前缀 xoxb 的应用程序。

使用此 token ,我向 the files.list 发出了 GET 请求使用 Postman 的端点:

GET https://slack.com/api/files.list?token=xoxb-xxxxxxxxxxxx-xxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxx&count=100&page=1&show_files_hidden_by_limit=true
HTTP/1.1
User-Agent: PostmanRuntime/7.24.1
Accept: */*
Cache-Control: no-cache
Postman-Token: 29879ef1-6da3-4863-8bb9-da8b4d5f740c
Host: slack.com
Accept-Encoding: gzip, deflate, br
Connection: keep-alive

HTTP/1.1 200 OK
date: Sat, 09 Jan 2021 18:18:42 GMT
server: Apache
x-xss-protection: 0
pragma: no-cache
cache-control: private, no-cache, no-store, must-revalidate
access-control-allow-origin: *
strict-transport-security: max-age=31536000; includeSubDomains; preload
x-slack-req-id: d972daab31ff4fe7a477eb3149ad5260
x-content-type-options: nosniff
referrer-policy: no-referrer
access-control-expose-headers: x-slack-req-id, retry-after
x-slack-backend: r
x-oauth-scopes: files:read,files:write
x-accepted-oauth-scopes: files:read
expires: Mon, 26 Jul 1997 05:00:00 GMT
vary: Accept-Encoding
access-control-allow-headers: slack-route, x-slack-version-ts, x-b3-traceid, x-b3-spanid, x-b3-parentspanid, x-b3-sampled, x-b3-flags
content-encoding: gzip
content-length: 87
content-type: application/json; charset=utf-8
x-envoy-upstream-service-time: 444
x-backend: files_normal files_canary_with_overflow files_control_with_overflow
x-server: slack-www-hhvm-files-iad-jc2v
x-via: envoy-www-iad-4782, haproxy-edge-iad-y1wa
x-slack-shared-secret-outcome: shared-secret
via: envoy-www-iad-4782
{
"ok": true,
"files": [],
"paging": {
"count": 100,
"total": 1803,
"page": 1,
"pages": 19
}
}

如您所见,响应包含一个空的 files[] 数组,但 paging 属性告诉我工作区中有 1803 个文件。

为什么我看不到工作区中的任何文件,即使我有适当的范围并收到 HTTP 200 响应?

最佳答案

我不知道这是否是的答案,但这是一个解决方法:

  • 授予应用程序 channels:readchannels:join 作用域
  • 调用conversations.list端点以获取工作区中的 channel 列表
  • 获取您要为其列出文件的 channel 之一的 id 属性
  • 调用conversations.join将应用程序添加到 channel 的端点
  • 调用files.list端点以获取该 channel 中的文件列表。

据推测,您可以遍历工作区中的每个公共(public) channel ,加入每个 channel ,列出其文件,然后删除早于特定日期的文件。

关于slack-api - 为什么 Slack 的 files.list 端点返回一个空文件数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65646097/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com