Reputation: 75
I want to insert a new parent for my file in Google Drive. This allows the file to be in two different folders at the same time with the same FileID. This is my code: (I'm running this on Node.js and using request Node package but this shouldn't make any difference anyways).
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);
});
However, I'm getting the following error:
{
"error": {
"errors": [{
"domain": "global",
"reason": "resourceRequired",
"message": "Resource metadata required"
}],
"code": 400,
"message": "Resource metadata required"
}
}
I've search Google Drive's API documentations but didn't find any relevant solutions.
Google Drive Parents insert API reference: https://developers.google.com/drive/v2/reference/parents/insert
Google Drive API parents resource schema: https://developers.google.com/drive/v2/reference/parents#resource
any help would be greatly appreciated :)
Upvotes: 0
Views: 385
Reputation: 22306
Instead of
'body': JSON.stringify({
id: PARENT_FOLDER_ID
})
try
'json': {
id: PARENT_FOLDER_ID
}
Upvotes: 1