Gscript code to send dummy parameters to google spreadsheet












1















I am trying to send the dummy values using Gscript code to my google spreadsheet.



Code:



 function doGet(e) { 
Logger.log( JSON.stringify(e) ); // view parameters
var result = 'Ok'; // assume success
if (e.parameter == 'undefined')
{
result = 'No Parameters';
}
else {
var sheet_id = 'google sheet ID /d<ID>/edit'; //
Spreadsheet ID
var sheet = SpreadsheetApp.openById(sheet_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 'tempC': //Parameter
rowData[1] = value; //Value in column B
result = 'Written on column B';
break;
case 'tempF': //Parameter
rowData[2] = value; //Value in column B
result = 'Written on column C';
break;
case 'humiD': //Parameter
rowData[3] = value; //Value in column C
result += ' ,Written on column D';
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);
}
/**
* Remove leading and trailing single or double quotes
*/
function stripQuotes( value ) {
return value.replace(/^["']|['"]$/g, "");
}
//-----------------------------------------------
// End of file
//-----------------------------------------------


I am new with this work and whenever I am using script id URL to post the dummy data to google spreadsheet



like below:






https://script.google.com/macros/s/<*GScript ID>/exec?tempC=1&tempF=2&humiD=3





then the error of unsupported parameters shown at my execution screen and even Logger. logs show "undefined" message.



If someone has worked with this kind of issue before please share your advice will be a great much help.



enter image description here










share|improve this question

























  • logs screenshot and execution transcript screenshot

    – TheMaster
    Nov 13 '18 at 14:21











  • I think that if Web Apps is correctly deployed, in your script, when users access to the endpoint including the query parameters of tempC=1&tempF=2&humiD=3, Written on column B is returned and the value of date, 1, 2, 3 is put to the spreadsheet. So as a solution, how about redeploying Web Apps as new version? By this, the latest script is reflected to Web Apps. If this was not the direct solution for your issue, I'm sorry.

    – Tanaike
    Nov 13 '18 at 22:23











  • Hi, TheMaster I have shared the screenshot as well as log message shows "Undefined", and Thanks Tanaike I did it with the newer version also but still the message shows "unsupported parameters"

    – varul jain
    Nov 15 '18 at 8:29











  • @var No you haven't. I asked for Logger logs and execution transcript.

    – TheMaster
    Nov 15 '18 at 11:27













  • @varul jain I'm really sorry. In my environment, I cannot replicate your situation. So for example, when you request to the Web Apps using curl, what result do you get?

    – Tanaike
    Nov 15 '18 at 23:05
















1















I am trying to send the dummy values using Gscript code to my google spreadsheet.



Code:



 function doGet(e) { 
Logger.log( JSON.stringify(e) ); // view parameters
var result = 'Ok'; // assume success
if (e.parameter == 'undefined')
{
result = 'No Parameters';
}
else {
var sheet_id = 'google sheet ID /d<ID>/edit'; //
Spreadsheet ID
var sheet = SpreadsheetApp.openById(sheet_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 'tempC': //Parameter
rowData[1] = value; //Value in column B
result = 'Written on column B';
break;
case 'tempF': //Parameter
rowData[2] = value; //Value in column B
result = 'Written on column C';
break;
case 'humiD': //Parameter
rowData[3] = value; //Value in column C
result += ' ,Written on column D';
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);
}
/**
* Remove leading and trailing single or double quotes
*/
function stripQuotes( value ) {
return value.replace(/^["']|['"]$/g, "");
}
//-----------------------------------------------
// End of file
//-----------------------------------------------


I am new with this work and whenever I am using script id URL to post the dummy data to google spreadsheet



like below:






https://script.google.com/macros/s/<*GScript ID>/exec?tempC=1&tempF=2&humiD=3





then the error of unsupported parameters shown at my execution screen and even Logger. logs show "undefined" message.



If someone has worked with this kind of issue before please share your advice will be a great much help.



enter image description here










share|improve this question

























  • logs screenshot and execution transcript screenshot

    – TheMaster
    Nov 13 '18 at 14:21











  • I think that if Web Apps is correctly deployed, in your script, when users access to the endpoint including the query parameters of tempC=1&tempF=2&humiD=3, Written on column B is returned and the value of date, 1, 2, 3 is put to the spreadsheet. So as a solution, how about redeploying Web Apps as new version? By this, the latest script is reflected to Web Apps. If this was not the direct solution for your issue, I'm sorry.

    – Tanaike
    Nov 13 '18 at 22:23











  • Hi, TheMaster I have shared the screenshot as well as log message shows "Undefined", and Thanks Tanaike I did it with the newer version also but still the message shows "unsupported parameters"

    – varul jain
    Nov 15 '18 at 8:29











  • @var No you haven't. I asked for Logger logs and execution transcript.

    – TheMaster
    Nov 15 '18 at 11:27













  • @varul jain I'm really sorry. In my environment, I cannot replicate your situation. So for example, when you request to the Web Apps using curl, what result do you get?

    – Tanaike
    Nov 15 '18 at 23:05














1












1








1








I am trying to send the dummy values using Gscript code to my google spreadsheet.



Code:



 function doGet(e) { 
Logger.log( JSON.stringify(e) ); // view parameters
var result = 'Ok'; // assume success
if (e.parameter == 'undefined')
{
result = 'No Parameters';
}
else {
var sheet_id = 'google sheet ID /d<ID>/edit'; //
Spreadsheet ID
var sheet = SpreadsheetApp.openById(sheet_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 'tempC': //Parameter
rowData[1] = value; //Value in column B
result = 'Written on column B';
break;
case 'tempF': //Parameter
rowData[2] = value; //Value in column B
result = 'Written on column C';
break;
case 'humiD': //Parameter
rowData[3] = value; //Value in column C
result += ' ,Written on column D';
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);
}
/**
* Remove leading and trailing single or double quotes
*/
function stripQuotes( value ) {
return value.replace(/^["']|['"]$/g, "");
}
//-----------------------------------------------
// End of file
//-----------------------------------------------


I am new with this work and whenever I am using script id URL to post the dummy data to google spreadsheet



like below:






https://script.google.com/macros/s/<*GScript ID>/exec?tempC=1&tempF=2&humiD=3





then the error of unsupported parameters shown at my execution screen and even Logger. logs show "undefined" message.



If someone has worked with this kind of issue before please share your advice will be a great much help.



enter image description here










share|improve this question
















I am trying to send the dummy values using Gscript code to my google spreadsheet.



Code:



 function doGet(e) { 
Logger.log( JSON.stringify(e) ); // view parameters
var result = 'Ok'; // assume success
if (e.parameter == 'undefined')
{
result = 'No Parameters';
}
else {
var sheet_id = 'google sheet ID /d<ID>/edit'; //
Spreadsheet ID
var sheet = SpreadsheetApp.openById(sheet_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 'tempC': //Parameter
rowData[1] = value; //Value in column B
result = 'Written on column B';
break;
case 'tempF': //Parameter
rowData[2] = value; //Value in column B
result = 'Written on column C';
break;
case 'humiD': //Parameter
rowData[3] = value; //Value in column C
result += ' ,Written on column D';
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);
}
/**
* Remove leading and trailing single or double quotes
*/
function stripQuotes( value ) {
return value.replace(/^["']|['"]$/g, "");
}
//-----------------------------------------------
// End of file
//-----------------------------------------------


I am new with this work and whenever I am using script id URL to post the dummy data to google spreadsheet



like below:






https://script.google.com/macros/s/<*GScript ID>/exec?tempC=1&tempF=2&humiD=3





then the error of unsupported parameters shown at my execution screen and even Logger. logs show "undefined" message.



If someone has worked with this kind of issue before please share your advice will be a great much help.



enter image description here






https://script.google.com/macros/s/<*GScript ID>/exec?tempC=1&tempF=2&humiD=3





https://script.google.com/macros/s/<*GScript ID>/exec?tempC=1&tempF=2&humiD=3






javascript google-apps-script google-sheets-api






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 15 '18 at 8:27







varul jain

















asked Nov 13 '18 at 12:11









varul jainvarul jain

558




558













  • logs screenshot and execution transcript screenshot

    – TheMaster
    Nov 13 '18 at 14:21











  • I think that if Web Apps is correctly deployed, in your script, when users access to the endpoint including the query parameters of tempC=1&tempF=2&humiD=3, Written on column B is returned and the value of date, 1, 2, 3 is put to the spreadsheet. So as a solution, how about redeploying Web Apps as new version? By this, the latest script is reflected to Web Apps. If this was not the direct solution for your issue, I'm sorry.

    – Tanaike
    Nov 13 '18 at 22:23











  • Hi, TheMaster I have shared the screenshot as well as log message shows "Undefined", and Thanks Tanaike I did it with the newer version also but still the message shows "unsupported parameters"

    – varul jain
    Nov 15 '18 at 8:29











  • @var No you haven't. I asked for Logger logs and execution transcript.

    – TheMaster
    Nov 15 '18 at 11:27













  • @varul jain I'm really sorry. In my environment, I cannot replicate your situation. So for example, when you request to the Web Apps using curl, what result do you get?

    – Tanaike
    Nov 15 '18 at 23:05



















  • logs screenshot and execution transcript screenshot

    – TheMaster
    Nov 13 '18 at 14:21











  • I think that if Web Apps is correctly deployed, in your script, when users access to the endpoint including the query parameters of tempC=1&tempF=2&humiD=3, Written on column B is returned and the value of date, 1, 2, 3 is put to the spreadsheet. So as a solution, how about redeploying Web Apps as new version? By this, the latest script is reflected to Web Apps. If this was not the direct solution for your issue, I'm sorry.

    – Tanaike
    Nov 13 '18 at 22:23











  • Hi, TheMaster I have shared the screenshot as well as log message shows "Undefined", and Thanks Tanaike I did it with the newer version also but still the message shows "unsupported parameters"

    – varul jain
    Nov 15 '18 at 8:29











  • @var No you haven't. I asked for Logger logs and execution transcript.

    – TheMaster
    Nov 15 '18 at 11:27













  • @varul jain I'm really sorry. In my environment, I cannot replicate your situation. So for example, when you request to the Web Apps using curl, what result do you get?

    – Tanaike
    Nov 15 '18 at 23:05

















logs screenshot and execution transcript screenshot

– TheMaster
Nov 13 '18 at 14:21





logs screenshot and execution transcript screenshot

– TheMaster
Nov 13 '18 at 14:21













I think that if Web Apps is correctly deployed, in your script, when users access to the endpoint including the query parameters of tempC=1&tempF=2&humiD=3, Written on column B is returned and the value of date, 1, 2, 3 is put to the spreadsheet. So as a solution, how about redeploying Web Apps as new version? By this, the latest script is reflected to Web Apps. If this was not the direct solution for your issue, I'm sorry.

– Tanaike
Nov 13 '18 at 22:23





I think that if Web Apps is correctly deployed, in your script, when users access to the endpoint including the query parameters of tempC=1&tempF=2&humiD=3, Written on column B is returned and the value of date, 1, 2, 3 is put to the spreadsheet. So as a solution, how about redeploying Web Apps as new version? By this, the latest script is reflected to Web Apps. If this was not the direct solution for your issue, I'm sorry.

– Tanaike
Nov 13 '18 at 22:23













Hi, TheMaster I have shared the screenshot as well as log message shows "Undefined", and Thanks Tanaike I did it with the newer version also but still the message shows "unsupported parameters"

– varul jain
Nov 15 '18 at 8:29





Hi, TheMaster I have shared the screenshot as well as log message shows "Undefined", and Thanks Tanaike I did it with the newer version also but still the message shows "unsupported parameters"

– varul jain
Nov 15 '18 at 8:29













@var No you haven't. I asked for Logger logs and execution transcript.

– TheMaster
Nov 15 '18 at 11:27







@var No you haven't. I asked for Logger logs and execution transcript.

– TheMaster
Nov 15 '18 at 11:27















@varul jain I'm really sorry. In my environment, I cannot replicate your situation. So for example, when you request to the Web Apps using curl, what result do you get?

– Tanaike
Nov 15 '18 at 23:05





@varul jain I'm really sorry. In my environment, I cannot replicate your situation. So for example, when you request to the Web Apps using curl, what result do you get?

– Tanaike
Nov 15 '18 at 23:05












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53280767%2fgscript-code-to-send-dummy-parameters-to-google-spreadsheet%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53280767%2fgscript-code-to-send-dummy-parameters-to-google-spreadsheet%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Xamarin.iOS Cant Deploy on Iphone

Glorious Revolution

Dulmage-Mendelsohn matrix decomposition in Python