With a couple of clicks, Appscript gives you a webserver including https certificate: for free!

Seriously? Does that mean I can push json-data into a spreadsheet (using appscript)?

Yes! Just make sure you’ll follow the CORS / authentication-logic below.

Not interested in CORS / authentication, but still curious about appscript? Read how to teach yourself appscript here

CORS caveats

Before you do your happy-dance (which you should), please understand appscript + CORS comes with a few exceptions:

  • GET requests: mostly yes
  • POST request: it depends
  • PUT/DELETE/OPTIONS: nope

Depends on what? Authentication and additional url-slug..

https://script.google.com/macros/s/...../exec was assumed as the appscript-url

Getting started with JSON

function doGet(request) {
  var result = {foo:"bar"}
  return ContentService.createTextOutput(JSON.stringify(result))
                       .setMimeType(ContentService.MimeType.JSON);
}

NOTE: for other mimetypes see here

Check Gexpress for a more simpler, express-style way of writing endpoints.

In order to get rid of the (not made by google) banner, you can try 2 things:

  • create a google site and include the script
  • include the script as an iframe on another domain (host on gitlab/github/bitbucket page e.g.)

DISCLAIMER: the author hasn’t tested this recently.

Further reading