Mairyu
Mairyu

Reputation: 839

Can I execute a Google App scripts via Sheets URL?

Can't get OAuth to work, so I settled for a public spreadsheet, able to download data via URL (range/value). Struggling to get upload data via JSON embedded in POST, then I thought I saw some other approach: Is it somehow possible to write an app script that writes a value to cell and embed that data in the URL together with the request to execute the app script ?

Basically, download data via GET and upload data via GET, sounds crazy ?

Upvotes: 0

Views: 1922

Answers (1)

Tesseract
Tesseract

Reputation: 8139

Sure. You just need a function called doGet and then you can deploy the script as a web app. Here is an example.

function doGet(e) {
  return ContentService.createTextOutput(JSON.stringify(e, null, 2));
}

If you then open the web app url with some parameters added to it e.g. https://script.google.com/macros/s/.../exec?a=3&b=4 you should see that those parameters are now contained in e so your script can just read them and add them to your spreadsheet.

Upvotes: 3

Related Questions