【发布时间】:2016-05-13 13:55:18
【问题描述】:
我想在 Google 云端硬盘中为我的文件插入一个新的父级。这允许文件同时位于具有相同 FileID 的两个不同文件夹中。这是我的代码:(我在 Node.js 上运行它并使用 request Node 包,但这不应该有任何区别)。
var request_url = 'https://www.googleapis.com/drive/v2/files/' + FILE_ID + '/parents/';
request.post({
"url": request_url,
'headers': {
'Authorization': 'Bearer ' + accessToken
},
'body': JSON.stringify({
id: PARENT_FOLDER_ID
})
}, function(response, body) {
console.log(body);
});
但是,我收到以下错误:
{
"error": {
"errors": [{
"domain": "global",
"reason": "resourceRequired",
"message": "Resource metadata required"
}],
"code": 400,
"message": "Resource metadata required"
}
}
我搜索了 Google Drive 的 API 文档,但没有找到任何相关的解决方案。
Google Drive 父母插入 API 参考: https://developers.google.com/drive/v2/reference/parents/insert
Google Drive API 父资源架构: https://developers.google.com/drive/v2/reference/parents#resource
任何帮助将不胜感激:)
【问题讨论】:
标签: javascript node.js google-drive-api http-post