Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To call a Google Apps Script using HTTP GET or POST requests, you need to publish your script as a web app. Here are the steps:

  1. Open your script in the Scripts Editor.
  2. Click on the "Publish" menu and select "Deploy as web app".
  3. In the "Deploy as web app" dialog, set access to "Anyone, even anonymous".
  4. Choose the version and submit the dialog.
  5. Note the deployed web app URL that is displayed.

To call the script using HTTP GET or POST, use the deployed web app URL with the appropriate HTTP method. For example, if your web app URL is "https://script.google.com/macros/s/<some-id>/exec", you can call it using:

  • HTTP GET: https://script.google.com/macros/s/<some-id>/exec?key1=value1&key2=value2
  • HTTP POST: https://script.google.com/macros/s/<some-id>/exec

In your Apps Script code, you can access the GET or POST parameters using the event object. For example:

function doGet(event) {
  var param1 = event.parameter["key1"];
  var param2 = event.parameter["key2"];
  // process the parameters...
}

function doPost(event) {
  // process the POST data...
}