node.js - 错误: Body attribute missing in multipart while using googleapis node module

标签 node.js request google-drive-api google-apis-explorer

我正在使用驱动器版本 2 将新文件插入到 google-drive。 使用 client.files.insert() 函数将新文件插入 Google 云端硬盘

我收到以下错误 错误:多部分中缺少正文属性。

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/

谁能帮帮我!!

最佳答案

确保您已启用 Drive API:

  • 转到Google Developers Console
  • 选择一个项目。
  • 在左侧边栏中选择API 和身份验证
  • 在可用 API 列表中找到Drive API,并将其状态设置为开启

关于node.js - 错误: Body attribute missing in multipart while using googleapis node module,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21822473/

相关文章:

laravel - 如何在没有 auth :api middleware in laravel 5. 3 的情况下对用户进行身份验证?

php - Google Drive API - PHP 客户端库 - 将 uploadType 设置为可恢复上传

java - Drive api 下载文件时出错

javascript - 如何使用 javascript 在 Google Drive 上创建文件夹

javascript - Google Drive API 获取缩略图

java - 收到致命警报 : handshake_failure webservice

node.js - 使用 Node HTTP 服务器发送新的请求响应

python urllib 错误

node.js - 为什么我们在设置Phonegap之前需要Nodejs?

node.js - 无法使用 tls 连接 node.js 中的 socket.io