I am trying to do transfering of file ownership to an emailaddress. I send this first request,
var body = {
'emailAddress': value,
'type': type,
'role': "writer"
};
var request = gapi.client.drive.permissions.create({
'fileId': fileId,
'transferOwnership': false,
'resource': body
});
request.execute(function(resp) {
...
});
This will create a permission writer for that emailaddress. After that, inside the request.execute() callback, I send the second request,
var request2 = gapi.client.drive.permissions.list({
'fileId': fileId
});
body.role = role;
request2.execute(function(resp2) {
var request3 = gapi.client.drive.permissions.update({
'fileId': fileId,
'permissionId': resp2.permissions[1].id, //permission id of writer
'transferOwnership': true,
'resource': {'role':role, 'emailAddress': value}
});
request3.execute(function(resp3) {
console.log(resp3);
});
});
In the above request, I used permissions.list to get the file permission id. Then I used the permission id to update permissions. I used permissions.update request for transferOwnership. The problem I encountered here is "The user does not have sufficient permissions for this file."
What I am trying to do here is transfer the file ownership to an emailaddress. What is wrong with my codes? How can I transfer file ownership?