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 8624633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:34:41+00:00 2026-06-12T07:34:41+00:00

Right now I’m using this code to upload files to Google Drive: https://stackoverflow.com/a/11657773/1715263 It

  • 0

Right now I’m using this code to upload files to Google Drive:
https://stackoverflow.com/a/11657773/1715263
It works fine with a textfile.

With the same code I’m trying to create a folder, using this information from Google:
https://developers.google.com/drive/folder

so Google says “Content-Type: application/json” goes into the header and “application/vnd.google-apps.folder” should be the mimetype in the body(?), thats what I’m doing in my code, which looks like this now:

function createFolder() 
{
    var access_token = googleAuth.getAccessToken();

    var json = JSON.stringify({
        mimeType: 'application/vnd.google-apps.folder',
        title: 'Folder',
    });

    var body =  "Content-Type: application/json" + "\r\n" +
                "Content-Length: " + json.length + "\r\n" + "\r\n" +
                json;

    gapi.client.request({

        'path': '/upload/drive/v2/files/',
        'method': 'POST',
        'params': {'uploadType': 'multipart'},
        'headers': {
            'Content-Type': 'application/json',
            'Authorization': 'Bearer ' + access_token,             
        },
        'body': body
    }).execute(function(file) { 
        document.getElementById("info").innerHTML = "Created folder: " + file;
    }); 

But it’s only creating a file named “Untitled”, it’s no folder and you can’t open it.

When I change the “Content-Type” in the “headers” section to “application/vnd.google-apps.folder” and remove the “body” part, it’s creating a folder named “Untitled”.

How can I get it to create a folder with a specific title?

  • 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-12T07:34:43+00:00Added an answer on June 12, 2026 at 7:34 am

    Finally got it working by googling Claudios code which led me to this piece of code: https://stackoverflow.com/a/11361392/1715263

    The important thing that changed is the ‘path’, its now “/drive/v2/files/” instead of “/upload/drive/v2/files/”.
    I just removed the ‘gapi.client.load’-function, added headers information and changed the bodys mimeType.

    So here’s the code:

    function createFolder() {
    
       var access_token = googleAuth.getAccessToken();
    
       var request = gapi.client.request({
           'path': '/drive/v2/files/',
           'method': 'POST',
           'headers': {
               'Content-Type': 'application/json',
               'Authorization': 'Bearer ' + access_token,             
           },
           'body':{
               "title" : "Folder",
               "mimeType" : "application/vnd.google-apps.folder",
           }
       });
    
       request.execute(function(resp) { 
           console.log(resp); 
           document.getElementById("info").innerHTML = "Created folder: " + resp.title;
       });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Right now I have an upload field while uploads files to the server. The
Right now I am writing some Python code to deal with massive twitter files.
Right now I am listing all of a users microposts using the code below.
Right now, I have code that looks something like this: Private Sub ShowReport(ByVal reportName
right now I'm creating an array and using: render :json => @comments This would
Right now when I run this it keeps clicking on the same button every
Right now, I've just some code which fetches the picture from the URL directly.
Right now I have a script that will get the last five files in
Right now I am using sqlite within a ios application, and I want to
Right now, I have three models Post, Comment and User (using Devise ) associated

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.