Languages
[Edit]
EN

Google Sheets / Apps Script - handle GET requests

0 points
Created by:
Olivier-Myers
364

This article will show you how to handle GET requests in Google Sheets (Apps Script).

You can use Google Apps Script like a web app - below we show you how to get a response after a GET request.

Practical example

1. Create doGet() function

GET requests are handled by the doGet() function. In the example below, when Apps Script gets a GET request, it will respond with a JSON object:

[{"message":"hello"}]

Google Sheets / Apps Script - handle GET requests

Steps

  1. Go to Tools -> Script editor.
  2. Paste this code:
function doGet() {
  var response = [{ message: 'hello'}]; // your response

  return ContentService
   .createTextOutput(JSON.stringify(response))
   .setMimeType(ContentService.MimeType.JSON)
}

2. Deploy a script as a web app

Steps

  1. Go to Deploy -> New deployment.
  2. From the select type list, select Web app.
  3. Fill in the name details and specify who has access to the deployment.
  4. After clicking Deploy you will get a deployment URL to which you can send GET requests.

See also

  1. Google Apps Script - Web Apps

Google Sheets

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join