【发布时间】:2021-01-20 08:21:45
【问题描述】:
我可以使用“我的云端硬盘”中的快捷方式或“我的云端硬盘”中的文件夹轻松创建 Google 文档文件的快捷方式。这个问题和回复How to create a shortcut in Google Drive Apps Script instead of multiple parents
对这有很大帮助但是,当我尝试对 G Suite 共享云端硬盘文件夹执行相同操作时,出现以下错误:
GoogleJsonResponseException:对 drive.files.insert 的 API 调用失败 错误:找不到文件:#FILE NUM
使用“我的云端硬盘”而非共享云端硬盘的代码是:
function createShortcut() {
const targetId = "TARGET DOCUMENT ID";
const shortcutName = "Test";
const folderId = "TARGET FOLDER ID";
const resource = {
shortcutDetails: { targetId: targetId },
title: shortcutName,
mimeType:"application/vnd.google-apps.shortcut",
supportsTeamDrives:true,
parents: [{id: folderId}]
};
const shortcut = Drive.Files.insert(resource);
}
我已经查阅了文档:https://developers.google.com/drive/api/v3/shortcuts,但没有运气。
【问题讨论】:
标签: google-apps-script google-api shortcut