function doPost(e) {
var p = JSON.parse(e.postData.contents);
var ss = SpreadsheetApp.openByUrl(p.sheetUrl);
var sh = ss.getSheetByName(p.sheetName) || ss.insertSheet(p.sheetName);
sh.clearContents();
var data = [p.headers].concat(p.rows);
sh.getRange(1, 1, data.length, p.headers.length).setValues(data);
return ContentService.createTextOutput("OK");
}