从 Google Drive API 获取操作项列表

Nic*_*nes 7 google-api google-api-java-client google-drive-api google-drive-shared-drive


嗨,大家好。

我一直在尝试使用 Google Drive API 来获取一个列表,其中包含使用 Spring Boot 和我公司域中所有文件(文档或电子表格)中分配的操作项google-api-services-drive,但我遇到了一些问题:

  • 看起来 API 上没有关于操作项的内容。
  • 评论是我能得到的最接近的,但它们不包括操作项信息。他们只有被提及的人的电子邮件。
  • 文档看起来广泛而不精确。例如,这里他们说文件资源包含一个indexableText属性,但它不存在于响应中。
  • 如Term for followup 中所述,查找 actionitems您可以应用查询来获取包含 action items 的文件。为什么该fullText字段在响应中不可用,或者某些其他等效属性无法查看实际内容并将其用作获取操作项的解决方法?

我只需要从评论中知道谁被分配到操作项。

有任何想法吗?

zig*_*hka 3

检索带有Comments: list指定fields为的操作项comments/replies/action

我同意你的观点,这并不简单,但有一种方法可以检索完整的评论内容,包括操作项。

  1. 使用Files:list指定q为fullText contains 'followup:actionitems',就像您提到的帖子中一样

  2. 对于每个检索项目,使用fileId方法Comments: list

  3. 为了更好地理解,首先指定fieldsfor Comments:listas *- 这将返回完整的响应,如下所示:
{
 "kind": "drive#commentList",
 "comments": [
  {
   "kind": "drive#comment",
   "id": "AAAAGlyxwAg",
   "createdTime": "2020-06-08T09:04:34.907Z",
   "modifiedTime": "2020-06-08T09:05:07.279Z",
   "author": {
    "kind": "drive#user",
    "displayName": "XXX",
    "photoLink": "//ssl.gstatic.com/s2/profiles/images/silhouette96.png",
    "me": true
   },
   "htmlContent": "+\u003ca href=\"mailto:YYY@YYY.com\" data-rawHref=\"mailto:YYY@YYY.com\" target=\"_blank\"\u003eYYY@YYY.com\u003c/a\u003e Could you please check the spelling?",
   "content": "+YYY@YYY.com Could you please check the spelling?",
   "deleted": false,
   "resolved": true,
   "quotedFileContent": {
    "mimeType": "text/html",
    "value": "Hello"
   },
   "anchor": "kix.94ksxclyqix",
   "replies": [
    {
     "kind": "drive#reply",
     "id": "AAAAGlyxwAo",
     "createdTime": "2020-06-08T09:05:02.999Z",
     "modifiedTime": "2020-06-08T09:05:02.999Z",
     "author": {
      "kind": "drive#user",
      "displayName": "YYY",
      "photoLink": "//ssl.gstatic.com/s2/profiles/images/silhouette96.png",
      "me": false
     },
     "htmlContent": "Will do!",
     "content": "Will do!",
     "deleted": false
    },
    {
     "kind": "drive#reply",
     "id": "AAAAGlyxwAs",
     "createdTime": "2020-06-08T09:05:07.279Z",
     "modifiedTime": "2020-06-08T09:05:07.279Z",
     "author": {
      "kind": "drive#user",
      "displayName": "YYY",
      "photoLink": "//ssl.gstatic.com/s2/profiles/images/silhouette96.png",
      "me": false
     },
     "deleted": false,
     "action": "resolve"
    }
   ]
  }
 ]
}

Run Code Online (Sandbox Code Playgroud)

该响应包含以下信息:

  • 引用的文件内容(注释引用的文本)
  • 最初评论和回复的内容
  • 被分配评论的用户
  • 用户的回复,包括他的用户名
  • 最后,用户采取的操作

  1. 现在,如果您对所有字段不感兴趣而只对操作感兴趣,您可以看到这action是一个嵌套在comments/replies
  2. 要查询action,请将*in替换fields为comments/replies/action

至于您的问题indexableText,文档contentHints指定它是和的属性

contentHints
有关文件内容的附加信息。
这些字段永远不会在响应中填充。

使indexableText“有用”的一种方法是将其应用于诸如

Files:list和q:fullText contains 'indexableText'

好消息是,如果您对现在检索操作的方式不满意并且可以想到更好的方法来实现它,您可以在 Google 的公共问题跟踪器上提交功能请求。如果有足够多的用户对该功能表现出兴趣,谷歌可能会在未来实施它。