2014-02-17 28 views
1

我正在使用驅動器版本2向Google驅動器插入新文件。 使用client.files.insert()函數將新文件插入到谷歌驅動器錯誤:在使用googleapis節點模塊時multipart中缺少身體屬性

我收到以下錯誤 錯誤:多部分中缺少正文屬性。

var auth = new googleapis.OAuth2Client(); 

auth.setCredentials({ 
    access_token: 'accesskey' 
}); 

googleapis.discover('drive', 'v2').execute(function(err, client) { 
    client.drive.files.insert({ title: 'Test', mimeType: 'application/json' }) 
    .withMedia('application/json', "Hello world") 
    .withAuthClient(auth) 
    .execute(function(error,result){ 
    if(error){ 
     console.log(error); 
    }else{ 
     console.log(result); 
    } 
}); 

上面的代碼中存在的文檔:https://github.com/google/google-api-nodejs-client/

可以在任何幫助我!

回答

0

確保已啓用驅動器API:

  • 轉到Google Developers Console
  • 選擇一個項目。
  • 選擇API &驗證碼在左側欄。
  • 在可用的API列表中找到Drive API,並將其狀態設置爲ON