I’m making a callout using named credentials and trying to update the parent Id of the G-Drive file. While doing the callout, getting the below error.

"error": { "errors": [ { "domain": "global", "reason": "cannotAddParent", "message": "Increasing the number of parents is not allowed" } ], "code": 403, "message": "Increasing the number of parents is not allowed" } }

And here is the apex restapi callout to change the parent id of the file.

Http http = new Http();

HTTPResponse response;
HttpRequest request;
String folderId = '1iXXXXXXXXXXXXXXXXXXXXXXXXXXX'; // G-Suite folder id
String body = '{"id": "'+folderId+'"}';   

// Initialize the request Instance
request = new HttpRequest();
request.setHeader('content-type', 'application/json');
request.setEndpoint('callout:XXXXXXCloudGDrive'+'/'+fileId+'/parents'); // named cred 

response = http.send(request); 

Any Idea on How to update the parent id(folder Id) of a GDrive File using Apex callout?

On the documentation, they provide a method to remove parent of the file from the current folder. How can we achieve this in Apex ? https://developers.google.com/drive/api/v3/multi-parenting

  • 3
    it sounds to me, like a question related to google API, but not to salesforce itself. Nov 26, 2021 at 8:53

1 Answer 1


According to an error message, the very first sentence of Google Drive API Guide says:

Beginning Sept. 30, 2020, you will no longer be able to place a file in multiple parent folders; every file must have exactly one parent folder location. Instead, you can use a combination of status checks and a new shortcut implementation to accomplish file-related operations.

I can assume that an error is related to this, and has nothing to do with Apex itself.

  • Thanks for the answer. But I don't want to share the file to multiple folders, want to move the file from one to another. That's is possible according to the guide. But I'm not sure via apex. That's my question.
    – am_Aravi
    Nov 26, 2021 at 9:26

Not the answer you're looking for? Browse other questions tagged .