我必须使用Drive REST API为单个文件夹创建多个用户权限。如果我为每个用户连续请求(多个)(因为文档列表API batchACL已弃用)它会为每个用户返回permissionIds,但大多数时候只有一个用户授予了权限。这导致我的应用程序出错。我移动到Google Batch Requests并且我的请求postBody就是这样生成的,
var postBody = "";
dataObj.users.forEach(function (entry) {
var batchBody = {role: entry.role, type: "user", value: entry.email };
batchBody = JSON.stringify(batchBody);
postBody = postBody.concat("--batch_", collectionId, "\n");
postBody = postBody.concat("Content-Type: application/http \n");
postBody = postBody.concat("Content-ID: ", entry.email, "\n");
postBody = postBody.concat("Content-Transfer-Encoding: binary \n");
postBody = postBody.concat("POST /drive/v2/files/", collectionId, "/permissions \n");
postBody = postBody.concat("Content-Type: application/json \n");
postBody = postBody.concat("Content-Length: ", batchBody.length, " \n");
postBody = postBody.concat(batchBody, " \n");
});
postBody = postBody.concat("--batch_", collectionId, "--");
它以200返回成功,而响应体就是这样,
--batch_vfFEpoYZl9Q_AAYPEVhdVNI--
--batch_vfFEpoYZl9Q_AAYPEVhdVNI--
但未授予任何用户权限。根据Google文档,响应机构不应该这样。有人可以帮助我找到问题或使用“google-api-nodejs-client”执行相同批处理请求的任何指导吗?