Drive Api v3:更改监视请求TeamDriveId是否被忽略?

时间:2019-04-23 12:06:07

标签: google-api google-drive-api google-drive-team-drive

我正在尝试根据此处的文档指定要观看的Team Drive:https://developers.google.com/drive/api/v3/reference/changes/watch

  

teamDriveId |字符串从中返回更改的团队驱动器。如果已指定,更改ID将反映团队精神;使用组合的Team Drive ID并将更改ID作为标识符。

(注意,不建议使用teamDriveId,而建议使用driveId,但文档并未反映出来)

我读这句话的意思是,如果您仅提供与该文件夹(文件)相关的更改,并且其子级将引起推送通知,但我仍会收到有关该用户的云端硬盘中任何更改的通知。我看错文档了吗?

我最初是posted the question to the DotNet client library repo,因为我在C#中正在这样做。乔恩·斯凯特(Jon Skeet)建议IncludeItemsFromAllDrives应该是false,这似乎很合逻辑,因此我首先尝试了这一点。但是,这导致从API端点返回以下错误:

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "includeTeamDriveItemsRequired",
    "message": "The includeItemsFromAllDrives parameter must be set to true when driveId is specified or corpora contains drive or allDrives."
   }
  ],
  "code": 403,
  "message": "The includeItemsFromAllDrives parameter must be set to true when driveId is specified or corpora contains drive or allDrives."
 }
}

我尝试了以下属性的几种变体,以查看是否可以将其限制为Team Drive,但未成功:

  • SupportsTeamDrives
  • SupportsAllDrives
  • IncludeItemsFromAllDrives
  • RestrictToMyDrive

非常欢迎澄清。

修改:

根据要求提供的代码,以C#but the issue is likely to be the main API according to Jon Skeet格式:

Channel channel = new Channel()
{
    Id = Guid.NewGuid().ToString(),
    Type = "web_hook",
    Address = [address],
    Token = [token], //max 256 chars
    Expiration = new DateTimeOffset(DateTime.Now.AddMinutes(10).ToUnixTimeMilliseconds(),
};

var watchRequest = _driveService.Changes.Watch(channel, startPageToken);
//watchRequest.SupportsTeamDrives = true;
watchRequest.SupportsAllDrives = true;
//watchRequest.TeamDriveId = rootFolderId;
//watchRequest.IncludeTeamDriveItems = true;
watchRequest.IncludeItemsFromAllDrives = true;
watchRequest.DriveId = rootFolderId;
watchRequest.RestrictToMyDrive = true;

channel = await watchRequest.ExecuteAsync();

我已经尝试了注释注释代码所示的几种变体。

0 个答案:

没有答案