vendredi 20 février 2015

How do I create a Google Sheets document via the Google Drive Javascript OAuth2 API?


Vote count:

0




I am trying to create a blank Google Sheets document in Google Drive from a browser based app. I am able to create a blank file with an unknown file type, but have not been able to create a Google Sheets document.


My code is as follows:



function createfile() {
var config = {
'client_id': '<putyourclient_idhere>',
'scope': 'http://ift.tt/JALASw'
};
gapi.auth.authorize(config, function() {

var request = gapi.client.request({
'path': '/upload/drive/v2/files',
'method': 'POST'
});

var callback = function(file) {
console.log(file)
};

request.execute(callback);


});
}


I have reviewed the documentation here: http://ift.tt/W3uLVH


And the following StackOverflow posts: Create a empty spreadsheet in google drive using google spreadsheet api (python )? How to create an empty Google doc / Spreadsheet


I realise that I need to use a mimeType of 'application/vnd.google-apps.spreadsheet'.


I have also been able to successfully create a blank Google Sheets document using the APIs Explorer, but have been unable to determine how this is working. It is doing a post request to:


With a request payload of:


{ "title": "This is a test", "mimeType": "application/vnd.google-apps.spreadsheet" }


But note that the URL is slightly different.



asked 1 min ago







How do I create a Google Sheets document via the Google Drive Javascript OAuth2 API?

1 commentaire: