0

I am trying to create a new folder in a shared drive through the Google Drive API. It keeps coming back with an error

Error: Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream at createError (C:\Users\SSC05\Desktop\project\PID\PID2\node_modules\axios\lib\core\createError.js:16) at dispatchHttpRequest (C:\Users\SSC05\Desktop\project\PID\PID2\node_modules\axios\lib\adapters\http.js:48) at new Promise () at Object.httpAdapter [as adapter] (C:\Users\SSC05\Desktop\project\PID\PID2\node_modules\axios\lib\adapters\http.js:20) at Gaxios. (C:\Users\SSC05\Desktop\project\PID\PID2\node_modules\gaxios\build\src\gaxios.js:65) at Generator.next () at C:\Users\SSC05\Desktop\project\PID\PID2\node_modules\gaxios\build\src\gaxios.js:19 at new Promise () at __awaiter (C:\Users\SSC05\Desktop\project\PID\PID2\node_modules\gaxios\build\src\gaxios.js:15) at Gaxios.request (C:\Users\SSC05\Desktop\project\PID\PID2\node_modules\gaxios\build\src\gaxios.js:60)

If I try to remedy that by doing fileMetaData.toString() I end up with an untitled file NOT in the shared drive. I can upload files just fine, so I know it's not a problem with the authorization. I am using the code given in the documentation. It is as follows...

function createFolder(auth) {
  const drive = google.drive({version: 'v3', auth});
  var fileMetadata = {
    'name': loadLog().name,  //A function that pulls a name from a login file
    'parents': [parentFileID],
    'mimeType': 'application/vnd.google-apps.folder'
  };
  drive.files.create({
    resource: fileMetadata,
    fields: 'id'
  }, function (err, file) {
    if (err) {
      // Handle error
      console.error(err);
    } else {
      console.log('Folder Id: ', file.id);
    }
  });
}
Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
David D.
  • 21
  • 1
  • 4
  • 1
    Hello David, do you have owner permission to that shared drive? – kvk30 Jan 14 '20 at 00:59
  • @kvk30 I am a manager on the shared drive. – David D. Jan 14 '20 at 13:27
  • Hello @DavidD.! Is the `loadLog().name` parameter passed correctly? Is it a string? – ale13 Jan 14 '20 at 13:44
  • Hello @ale13 Yes, it does. I even tried hard coding a name for testing purposes, and it still didn't work. – David D. Jan 14 '20 at 17:33
  • @DavidD. from the details you provide it seems to me that the error is **not** in the code snippet you provided. Do you have any others that might be of help? Cheers! – ale13 Jan 15 '20 at 08:47
  • @ale13 Sorry it took me so long to reply. I ended up doing what I needed to do without creating the folder. I don't know what else could have been affecting it. In the same js file I was able to upload files, list files, and pull files. The only thing I wasn't able to do was create a folder. – David D. Jan 16 '20 at 17:18

1 Answers1

0

I came across this an answer where my google drive API service call had to pass this argument:

 supportsAllDrives=True

before my API call could access or interact with a shared drive.

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 25 '22 at 08:27