更新时间:2022-12-03 21:01:24
您使用了错误的端点.您将发布到 content
端点,而不是 file
端点.
You've used the wrong endpoint. Instead of the file
endpoint, you're posting to the content
endpoint.
所以
req.setEndpoint(' https://www.googleapis.com/upload/drive/v2/files ');
(对于v2 API)应为
should be (for the v2 API)
req.setEndpoint(' https://www.googleapis.com/drive/v2/文件');
或(对于v3 API)
or (for the v3 API)
req.setEndpoint(' https://www.googleapis.com/drive/v3/文件');
如果使用v3(您可能应该使用),则json应该会因此更改
If you use v3 (which you probably should), your json should change thus
String jsonData ='{"name":"NewFolder","mimeType":"application/vnd.google-apps.folder"}';
String jsonData = '{"name":"NewFolder", "mimeType":"application/vnd.google-apps.folder"}';