0
votes

I am not using sdk of google drive I want to upload a file on my google drive account thr my app for which I have used post api to which I have set url,headers,filename.But I get error as 'Bad content type.Use multipart'. My code is as follows-

File file = new File(fileName);

String url = "https://www.googleapis.com/upload/drive/v2/files/" + file.getName() + "?uploadType=multipart&access_token=" + accessToken;

headers.put("Content-type", "multipart/related");

response = GlobalConstants.SERVICE_CLIENT.Execute(url, "post", file, headers); //call to post.

Please do help at ur earliest Thnx in advance

1

1 Answers

0
votes

You need to read and understand this page https://developers.google.com/drive/v2/reference/files/insert.

Try the "try it now" link (https://developers.google.com/drive/v2/reference/files/insert#try-it) and look at how the URL and payload is formed, then your app needs to recreate that. The URL in your code is nothing like the URL required by the Drive API.