首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么斯莱克的files.list端点返回一个空文件数组?

为什么斯莱克的files.list端点返回一个空文件数组?
EN

Stack Overflow用户
提问于 2021-01-09 18:24:03
回答 1查看 408关注 0票数 3

我想使用Slack从我的工作区删除旧文件,因为我们已经没有空间来上传新的文件了。

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

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

代码语言:javascript
复制
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作为响应?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-01-09 18:36:24

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

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

想必,您可以遍历工作区中的每个公共通道,加入每个通道,列出其文件,然后删除超过某个日期的文件。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65646097

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档