用于更新/修补程序的谷歌驱动器权限API损坏

时间:2014-05-08 23:10:16

标签: google-drive-api

用于更新/修补的Google云端硬盘权限API无法按预期工作。更新/修补程序将添加为新权限,而不是更新现有权限。文档清楚地说它应该更新现有的权限。还有其他人看到同样的问题吗?感谢任何帮助。

在补丁列表输出::

之前
{
  "kind": "drive#permission",
  "etag": "\"7_qGCxxuhPBUXrfn7_2ZO3McVUQ/LsilxThzTS3OBJ1rbF7YEIEg1oo\"",
  "id": "08822980745812584915i",
  "selfLink": "...",
  "emailAddress": "XXXXXX@yahoo.com",
  "domain": "yahoo.com",
  "role": "writer",
  "type": "user"
}

补丁请求/响应::

PATCH https://www.googleapis.com/drive/v2/files/1SUds1Cjnr8xKzekkWqx9ECsUZXbEOLUGKFKb4y_LUwo/permissions/08822980745812584915i?key={YOUR_API_KEY}

Content-Type:  application/json
Authorization:  Bearer ya29.1.AADtN_WduvpsYzvK9o_skeJ-LkpJgkWeW3tFMxEN4gBv1pVU4tEM-ClpfYLXp65GqnodScrj-L5qaDA
X-JavaScript-User-Agent:  Google APIs Explorer

{
  "role": "reader"
}

{
  "kind": "drive#permission",
  "etag": "\"7_qGCxxuhPBUXrfn7_2ZO3McVUQ/lEg2fxSB9Duh6yZZqNOBgWKW5JY\"",
  "id": "08822980745812584915i",
  "selfLink": "...",
  "emailAddress": "XXXXXX@yahoo.com",
  "domain": "yahoo.com",
  "role": "reader",
  "type": "user"
}

补丁::

后的列表输出
{
  "kind": "drive#permission",
  "etag": "\"7_qGCxxuhPBUXrfn7_2ZO3McVUQ/ohtKstgNWK6Bocb03Cur-LaeY2g\"",
  "id": "00371221158164555836",
  "selfLink": "...",
  "name": "",
  "domain": "",
  "role": "reader",
  "type": "user"
},
{
  "kind": "drive#permission",
  "etag": "\"7_qGCxxuhPBUXrfn7_2ZO3McVUQ/LsilxThzTS3OBJ1rbF7YEIEg1oo\"",
  "id": "08822980745812584915i",
  "selfLink": "...",
  "emailAddress": "XXXXXX@yahoo.com",
  "domain": "yahoo.com",
  "role": "writer",
  "type": "user"
}

如您所见,它创建了一个新的权限,域名和域名为空。权限id在列表输出和补丁请求中相同

1 个答案:

答案 0 :(得分:0)

这对我有用。您是否有可能传递错误的权限ID?确保它在列表响应和补丁请求之间匹配。

原始列表回复:

...

 {

   "kind": "drive#permission",
   "etag": "<...>",
   "id": "01850103618484623959",
   "selfLink": <...>,
   "name": "Bob Dole",
   "domain": "",
   "role": "writer",
   "type": "user"
  }

...

补丁请求:

PATCH https://www.googleapis.com/drive/v2/files/0B2bhoijNAMV2UU9iMkpGbWktckxxSS1ra1lkQ0lTN052bWFn/permissions/01850103618484623959?key={YOUR_API_KEY}

Content-Type:  application/json
Authorization:  Bearer ya29.1.AADtN_VTwYJGkJw1SDuRf3S-n19-yZggimhaZLqmbOPlWjLiRCCEIknswZhccWgaKMIgf62IC6TcJK0
X-JavaScript-User-Agent:  Google APIs Explorer

{
 "role": "reader"
}

新列表回复:

...

   "kind": "drive#permission",
   "etag": "<...>",
   "id": "01850103618484623959",
   "selfLink":<...>,
   "name": "Bob Dole",
   "domain": "",
   "role": "reader",
   "type": "user"
  }

...