question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

drive.files.create throws the error: Invalid multipart request with 0 mime parts

See original GitHub issue

With "google-auth-library": "1.3.2" and "googleapis": "27.0.0" installed uploading to drive throws the Invalid multipart request with 0 mime parts error. Here is the code:

const {OAuth2Client} = require('google-auth-library')
const {google} = require('googleapis')

const googleOAuth2Client = new OAuth2Client({clientId: GOOGLE_DRIVE_CLIENT_ID})
googleOAuth2Client.setCredentials(tokens)
const googleDrive = google.drive({
  version: 'v3',
  auth: googleOAuth2Client
})

googleDrive.files.create({
  resource: {
    name: 'test.png',
    parents: [parentId]
  },
  media: {
    mimeType: 'image/png',
    body: fs.createReadStream('/Users/dmitry/Desktop/test.png')
  }
}, function (err, response) {
  if (err) {
    console.error(err)
    reject(err)
    return
  }
  console.log(response.data)
})

As mentioned here and here, it works with "googleapis": "24.0.0", so it looks like the request -> axios change is the reason for this issue. Or am I missing something? There is no much information in the code sample on github (yeah, I realize that all the code samples from docs are currently not working).

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
DSnopovcommented, Aug 8, 2019

This issue was reintroduced after replacing axios with gaxios in v37.0.0 . Again, it only happens in Electron renderer process.

0reactions
m4heshdcommented, Aug 15, 2021

@DSnopov This is my 2nd day being wasted on trying to find a solution for this other than IPC. Any workaround?

UPDATE: Only workaround is to use a custom fork. More details in #2714.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix Invalid multipart request with 0 mime parts error
This modified script supposes that your environment can upload files using Drive API. If the error related to API occurs, please confirm whether ......
Read more >
Google Drive Upload API - Invalid multipart request with 0 ...
Google Drive SDK with Node.js googleapis package throws Error: Invalid multipart request with 0 mime parts on files.create · Upload file in node...
Read more >
HTTP response code 400 with body: Invalid multipart request ...
After initial configuration, few files went through in a copy without ... code 400 with body: Invalid multipart request with 0 mime parts....
Read more >
Upload file data | Google Drive
A multipart upload request lets you upload metadata and data in the same request. Use this option if the data you send is...
Read more >
"Invalid multipart file in request" error for Gmail ...
2) Check the Content-Type if you are sending any attachment as multipart. Below might help you to understand some of the basics of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found