Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8669607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:31:01+00:00 2026-06-12T18:31:01+00:00

I am trying to create a new document on Google Drive from my android

  • 0

I am trying to create a new document on Google Drive from my android application using Google Drive SDK. My authentication is working and I have managed to create a simple text file with this code:

// com.google.api.services.drive.model.File
File newFile = new File();
newFile.setTitle("Test");
newFile.setMimeType("text/plain");
String contentStr = "This is a test file";      

try {
    File insertedFile = drive.files().insert(
         newFile, ByteArrayContent.fromString("text/plain", contentStr)).execute();
} catch (IOException e) {
    e.printStackTrace();
}

If I change “text/plain” to “application/vnd.google-apps.document” and insert the file without any content it works and a new document is created on my Google Drive:

// com.google.api.services.drive.model.File
File newFile = new File();
newFile.setTitle("Test");
newFile.setMimeType("application/vnd.google-apps.document");   

try {
    File insertedFile = drive.files().insert(newFile).execute();
} catch (IOException e) {
     e.printStackTrace();
}

But I want to upload a new document with content but when using the same approach as with the plain text file:

// com.google.api.services.drive.model.File
File newFile = new File();
newFile.setTitle("Test");

String fileType = "application/vnd.google-apps.document";
newFile.setMimeType(fileType);   

try {
    File insertedFile = drive.files().insert(
              newFile, ByteArrayContent.fromString(fileType, contentStr)).execute();
} catch (IOException e) {
    e.printStackTrace();
}

I get this error:

 com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
 {
     "code" : 400,
     "errors" : [ {
          "domain" : "global",
          "message" : "Bad Request",
          "reason" : "badRequest"
     } ],
     "message" : "Bad Request"
 }

And no file is created. Please can someone help me?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T18:31:03+00:00Added an answer on June 12, 2026 at 6:31 pm

    The mime type must be the mime type of the source document, eg text/plan or text/HTML. If you upload with convert=true, the resulting file on Drive will have a mime type of application/vnd.google-apps.document.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to simply create a new document using the Zend Google Docs API's
I am trying to create a new web application using PowerShell. I keep getting
Im trying to create new file on D: drive with c/c++ I found this
I'm trying to create a new project using tomcat 7.0.27 + JSF 2.1.7 +
i am trying to create a google document that has a paragraph automatically generated
I am trying to create a custom google map using Longitudes and Latitudes that
I'm trying to create map (using the Google Maps JavaScript API V3 ) which
I am trying to set Google Chart using API generated from below link Google
I am trying to create a sitemap for google from info supplied from my
I am working with Google Maps and I am trying to create a sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.