我总是得到:
多部分体中缺少结束边界。
API Sandbox没有帮助。可以在那里创建文件夹。
请求是: curl https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart -d @ / home / payload -H'授权:Bearer mytoken' -H'内容类型:multipart / boundary;边界= RubyApiClientUpload'
有效载荷是:
--RubyApiClientUpload
Content-Type: application/json
{ "mimeType":"application/vnd.google-apps.folder", "name":"newfolder", "parents":["0AMtAREF....."] }
--RubyApiClientUpload
--RubyApiClientUpload--
答案 0 :(得分:0)
您正在使用错误的API调用。文件夹没有内容,因此您可以通过POST到https://developers.google.com/drive/v3/reference/files/create
中的网址来创建它您可以在应该看到的https://developers.google.com/drive/v3/reference/files/create#try-it处轻松测试
POST https://www.googleapis.com/drive/v3/files?key={YOUR_API_KEY}
{
"mimeType": "application/vnd.google-apps.folder",
"name": "test folder"
}
答案 1 :(得分:0)
此代码适用于我。
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
});