Google Drive API v3:如何在文件上设置canCopy功能

时间:2018-10-28 12:00:52

标签: google-drive-api google-client

我想限制个人Google云端硬盘中文件的功能。当我将API资源管理器Google Drive v3 API用于以下请求时:

POST https://www.googleapis.com/drive/v3/files?key={YOUR_API_KEY}

{
 "capabilities": {
  "canCopy": false
 },
 "name": "testfile"
}

我收到以下答复:

403


- Show headers -

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "fieldNotWritable",
    "message": "The resource body includes fields which are not directly writable."
   }
  ],
  "code": 403,
  "message": "The resource body includes fields which are not directly writable."
 }
}

与尝试更新文件时得到的响应相同:

PATCH https://www.googleapis.com/drive/v3/files/FileIdHere?key={YOUR_API_KEY}

{
 "capabilities": {
  "canCopy": false
 }
}

似乎没有方法可以做到这一点,或者有人可以解决吗?

1 个答案:

答案 0 :(得分:0)

如果您选中file resource,您会注意到某些字段是可写的,而其他字段则不是。

您看到的消息是因为您要设置的字段不可写,这意味着您无法通过API进行更改