1
votes

I am trying to upload a CSV as a Google spreadsheet

I do see that there is a request parameter convert=true available at

Google Developer - insert.

Can some one help me on how to set this flag in Java API?

1

1 Answers

3
votes

The Drive.Files.Insert class has a setConvert method that you can use before calling execute. Using the file.insert sample as reference, you have to replace the following line:

File file = service.files().insert(body, mediaContent).execute();

with:

File file = service.files().insert(body, mediaContent).setConvert(true).execute();