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.setMethod('POST');
request.setHeader('content-type', 'application/json');
request.setEndpoint('callout:XXXXXXCloudGDrive'+'/'+fileId+'/parents'); // named cred
request.setBody(body);
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