Using Google Apps ScriptDB and the ContentService as an REST server

What no server?

That’s right – you can serve up data from your Google Apps Script directly. In my post the other day, I showed how to use the Google Apps ScriptDB as a place to store the  Rest-Excel library. Now ideally, you’d want to get that out again by making a simple API call – but we dont have a server. With the new Google Apps Script ContentService, you dont need one.

Here’s all there is to it.

Create a doGet() module that looks like this.

function doGet(e) {
   return ContentService
            .createTextOutput(mcpher.getRestLibrary().serialize())
            .setMimeType(ContentService.MimeType.JSON);
}

 

Publish your app as a web app. – try the link below..
https://script.google.com/a/macros/mcpher.com/s/AKfycbzLqpnQ2ey8CKAMmzchb2n2FU-aiae0iTKPzAOfAgEpxGwaJgk/execYou get the contents of the scriptDB query. This is seriously useful. Next post I’ll show you how to pass parameters to query and potentially update the scriptDB.
About brucemcp 225 Articles
I am a Google Developer Expert and decided to investigate Google Apps Script in my spare time. The more I investigated the more content I created so this site is extremely rich. Now, in 2019, a lot of things have disappeared or don’t work anymore due to Google having retired some stuff. I am however leaving things as is and where I came across some deprecated stuff, I have indicated it. I decided to write a book about it and to also create videos to teach developers who want to learn Google Apps Script. If you find the material contained in this site useful, you can support me by buying my books and or videos.