【发布时间】:2019-03-23 00:17:02
【问题描述】:
我是我的谷歌驱动器的所有者,我可以使用以下代码打开“可共享链接”,但是当我想将其设置为私有时(基本上关闭可共享链接) 然后发生异常:
Google.GoogleApiException: 'Google.Apis.Requests.RequestError The owner of a file cannot be removed. [403] Errors [ Message[The owner of a file cannot be removed.] Location[ - ] Reason[cannotRemoveOwner] Domain[global] ]
我可以轻松设置文件的权限:
var permission = new Google.Apis.Drive.v3.Data.Permission();
permission.Role = "reader";
permission.Type = "anyone";
var aaaa = Authentication.service.Permissions.Create(permission, fileIdAction).ExecuteAsync();
这是我的代码(不起作用):
//Get PermissionId
var get = Authentication.service.About.Get();
get.Fields = "*";
var permissionId = get.Execute().User.PermissionId;
//Delete method
Authentication.service.Permissions.Delete(fileIdAction, permissionId).Execute();
我认为permissionId 可能是一个问题,所以我尝试了不同的方法来获取它,但是,它们都不起作用(例外 - 关于所有者)。就像在这个线程中一样 - How to get permissionId in Drive API v3?
关于如何将文件设置回私有的任何想法?感谢您的帮助。
【问题讨论】:
标签: google-drive-api