我想用REST使用REST的Get方法获取共享驱动器,如果我在API页面上,尝试了API,它工作了,收到了200个响应,但当我在Apps Script上运行代码时,它说,Share Drive not found。
{error={errors=[{locationType=参数, reason=notFound, domain=global, message=Shared drive not found: DriveID, location=driveId}], code=404.0, message=未找到共享驱动器。 DriveID}}。
这是我的代码。
function getDrives(){
var service = getDriveService();
//get Drives
service.reset()
if(service.hasAccess){
var urlDrive = 'https://www.googleapis.com/drive/v3/drives/myDriveId?useDomainAdminAccess=true&key=myAPIKey HTTP/1.1';
var outputDrives = UrlFetchApp.fetch(urlDrive, {
method: 'get',
headers: { 'Authorization': 'Bearer ' + service.getAccessToken() },
contentType: 'application/json',
muteHttpExceptions: true
}).getContentText();
var responseDrives = JSON.parse(outputDrives);
Logger.log(responseDrives)
}
//end of getting drives
}
我尝试了所有可能的解决方案,但没有任何效果。希望有人能帮助我。先谢谢你了。
尝试添加:supportsAllDrives:true。(我在node API中使用这个来访问共享驱动器)
var urlDrive = 'https://www.googleapis.com/drive/v3/drives/myDriveId?useDomainAdminAccess=true&key=myAPIKey HTTP/1.1';
var outputDrives = UrlFetchApp.fetch(urlDrive, {
method: 'get',
headers: { 'Authorization': 'Bearer ' + service.getAccessToken() },
contentType: 'application/json',
muteHttpExceptions: true,
supportsAllDrives: true,
includeItemsFromAllDrives: true
}).getContentText();
希望能成功。