I would like to discuss with anyone here regarding my problem. My problem is that, I cannot successfully test my code.gs in google script with two data when I deploy it as web app. When I test it only one data it say 'Ok', but when I try to test adding a second data it say 'unsupported parameter'.
When I deploy the script as web app, the link is as below:
https://script.google.com/macros/s/AKfycbyXlCLBDNzJGXWNkrEHtWP0jaxnpvX0dPUnXjwilioUd7up-SU/exec
how can I test it? Is it like,
[1]
https://script.google.com/macros/s/AKfycbyXlCLBDNzJGXWNkrEHtWP0jaxnpvX0dPUnXjwilioUd7up-SU/exec?BBTTempData=32.56&RTtempData=25.6
or
[2] https://script.google.com/macros/s/AKfycbyXlCLBDNzJGXWNkrEHtWP0jaxnpvX0dPUnXjwilioUd7up-SU/exec?BBTTempData=32.56/RTtempData=25.6
My code is just like below:
function doGet(e) {
Logger.log( JSON.stringify(e) ); // view parameters
var result = 'Ok'; // assume success
if (e.parameter == undefined) {
result = 'No Parameters';
}
else {
var id = '<mygooglespreadsheet_id>'; //docs.google.com/spreadsheetURL/d
var sheet = SpreadsheetApp.openById(id).getActiveSheet();
var newRow = sheet.getLastRow() + 1;
var rowData = [];
rowData[0] = new Date(); // Timestamp in column A
for (var param in e.parameter) {
Logger.log('In for loop, param='+param);
var value = stripQuotes(e.parameter[param]);
//Logger.log(param + ':' + e.parameter[param]);
switch (param) {
case 'BBTTempData': //Parameter
rowData[1] = value; //Value in column B
break;
case 'RTtempData':
rowData[2] = value;
break;
default:
result = "unsupported parameter";
}
}
Logger.log(JSON.stringify(rowData));
// Write new row below
var newRange = sheet.getRange(newRow, 1, 1, rowData.length);
newRange.setValues([rowData]);
}
// Return result of operation
return ContentService.createTextOutput(result);
}
function stripQuotes( value ) {
return value.replace(/^["']|['"]$/g, "");
}
The code, I get it in YouTube https://www.youtube.com/watch?v=tWTv4-QUQ0E
.
A discussion is good for me. Thanks.