簡體   English   中英

Apps Scripts Google Drive API能否與共享驅動器對話

[英]Can Apps Scripts Google Drive API talk with Shared Drives

總而言之,我在我的 Apps 腳本中使用 Google Drive API 和共享驅動器時遇到了問題。 當我運行下面的代碼時,我收到錯誤“GoogleJsonResponseException: API call to drive.permissions.insert failed with error: File not found.”

相同的代碼適用於“我的雲端硬盤”上的文件,因此這是共享雲端硬盤的問題。 代碼以我自己的身份運行,我是共享驅動器的所有者。 有任何想法嗎?

function insertPermission() {

  var resource = {
    // enter email address here
    value: 'xxxxxxxxx@xxxxxxx.com', 
    
    // choose from "user" or "group" if using a Google Group
    type: 'user',                
    
    // choose from: "owner", "writer" or "reader"
    role: 'writer'               
  };
  
  var optionalArgs = {
    sendNotificationEmails: false
  };
  Drive.
  Drive.Permissions.insert(resource, 'TokenIDGoesHere', optionalArgs);
  
}

解決方案

你好 ! 您需要將請求參數supportsAllDrives設置為true ,以便能夠向共享驅動器發出此類請求。

我希望這對你有所幫助。 讓我知道您是否需要其他任何內容,或者您是否不理解某些內容。 :)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM