0

I am just getting started with Google Apps Script and I want to be able to add to a Google Sheet through a web app, but I'm having issues. This is what I have so far:

function addRow(input) {
  var sheet = SpreadsheetApp.openByUrl('https://spreadsheeturl');
  sheet.appendRow([input]);
} 

function doGet(e) {
  var params = JSON.stringify(e);
  addRow(params);
  return HtmlService.createHtmlOutput(params);
} 

When I type in the URL they give me with the parameters I want to add to the spreadsheet it doesn't add anything to the spreadsheet, but if I don't pass any parameters it adds it to the spreadsheet.

For example, https://script.google.com/.../exec adds {"parameter":{},"contextPath":"","contentLength":-1,"queryString":"","parameters":{}} to the spreadsheet, but https://script.google.com/.../exec?user=jsmith doesn't add anything to the spreadsheet.

Reading the documentation I can see something about URL parameters and event objects, but they give no further information. What's the problem and how can I fix it?

Thanks,
Tomi

1 Answer 1

1

I think that your script works. In your script,

  • When https://script.google.com/.../exec is requested, {"parameter":{},"contextPath":"","contentLength":-1,"queryString":"","parameters":{}} is added to the last row at the 1st sheet of the Spreadsheet.
  • When https://script.google.com/.../exec?user=jsmith is requested, {"parameter":{"user":"jsmith"},"contextPath":"","contentLength":-1,"queryString":"user=jsmith","parameters":{"user":["jsmith"]}} is added to the last row at the 1st sheet of the Spreadsheet.

So can you confirm the following points on your script editor again?

  1. At Publish -> Deploy as web app, redeploy as a new version for Project version:.
    • When the scripts for Web Apps was modified, the modified script is required to be redeployed as a new version. By this, the modified script is reflected to Web Apps.
  2. At Publish -> Deploy as web app, it confirms whether Execute the app as: and Who has access to the app: are "me" and "Anyone, even anonymous", respectively.

If I misunderstand your question, I'm sorry.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.