Created
August 17, 2015 21:18
-
-
Save qgustavor/fd6cd8fcc61120d6c624 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ss = SpreadsheetApp.openById('Your spreadsheet id'); | |
function doPost(e) { | |
var returnedData = {}; | |
// Retrieve and process any URL parameters, as necessary. | |
var data = e.parameter.data; | |
try { | |
addRow(data); | |
returnedData.result = 'OK'; | |
} catch (e) { | |
returnedData.result = 'FAILED'; | |
returnedData.error = e.toString(); | |
} | |
if (e.parameter.callback) { | |
return ContentService.createTextOutput( | |
e.parameter.callback + '(' + JSON.stringify(returnedData) + ');') | |
.setMimeType(ContentService.MimeType.JAVASCRIPT); | |
} | |
return ContentService.createTextOutput(JSON.stringify(returnedData)) | |
.setMimeType(ContentService.MimeType.JSON); | |
} | |
function addRow(exampleData) { | |
var sheet = ss.getSheetByName('TestSheet'), | |
lastRow = sheet.getLastRow(); | |
sheet | |
.getRange(lastRow + 1, 1, 1, 1 /* row count */) | |
.setValues([[ | |
exampleData | |
]]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment