1
votes

I always get:

Missing end boundary in multipart body.

API Sandbox doesn't help. It is possible to create folder there.

The request is: curl https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart -d @/home/payload -H 'Authorization: Bearer mytoken' -H 'Content-Type: multipart/boundary; boundary=RubyApiClientUpload'

The payload is:

--RubyApiClientUpload 
Content-Type: application/json

{   "mimeType":"application/vnd.google-apps.folder",   "name":"newfolder",   "parents":["0AMtAREF....."] }
--RubyApiClientUpload

--RubyApiClientUpload--
2

2 Answers

0
votes

You're using the wrong API call. A folder has no content, so you create it by POSTing to the URL in https://developers.google.com/drive/v3/reference/files/create

You can easily test it at https://developers.google.com/drive/v3/reference/files/create#try-it where you should see POST https://www.googleapis.com/drive/v3/files?key={YOUR_API_KEY} { "mimeType": "application/vnd.google-apps.folder", "name": "test folder" }

0
votes

This code works for me.

  const body = JSON.stringify({
     name: "Super folder!!!",
     mimeType: "application/vnd.google-apps.folder"
  });

  const headers = new Headers();

  headers.append("Authorization", `Bearer ${accessToken}`);
  headers.append("Content-Type", "application/json");
  headers.append("Content-Length", body.length);

  fetch(
     "https://www.googleapis.com/drive/v3/files", {
        method: "POST",
        headers,
        body
     });