In your situation, please include supportsAllDrives
to the query parameter. When the script in this thread is modified, it becomes as follows.
From:
var resource = {
title: sheet_Name+".csv",
mimeType: "application/vnd.csv"
parents: [{ id: folder_id }]
}
var fileJson = Drive.Files.insert(resource,result)
To:
var folderId = "###"; // Please set the folder ID of your shared Drive.
var resource = {
title: sheet_Name + ".csv",
mimeType: MimeType.CSV,
parents: [{id: folderId}]
}
var fileJson = Drive.Files.insert(resource, result, {supportsAllDrives: true});
Note:
- In this modified script, it supposes that you have the permission for writing the file in the shared Drive. Please be careful this.
Reference: