I want to create several individual URLs (in other words, endpoints) for a particular sheet in a given document. I have data (not much, about 200-250 rows). Basically, data structure is exactly the same every year (ID, Country, Title, Name etc.). I have managed to transform selected cells into proper JSON format and deploy the following as a Web Application.
I'm currently using the doGet()
method, which body can be found below.
I tried to use official Google Documentation, but it seems to me that I do not fully understand it.
https://developers.google.com/apps-script/guides/web#url_parameters
function doGet(e)
{
var sheetName = "Lorem Ipsum";
var sheetID = "SDJHFLKSDJFLJSD94UF940FUJ9FS90FJ049JW9F";
var book = SpreadsheetApp.openById(sheetID);
var sheet = book.getSheetByName(sheetName);
var JSON = convertSheet2JsonText(sheet);
return ContentService.createTextOutput(JSON.stringify(JSON)).setMimeType(ContentService.MimeType.JSON);
}
[
{
"ID": 1,
"PUBLISHED": true,
"NAME": "Lorem Ipsum",
"TITLE": "Lorem Ipsum",
"SOURCE": "Lorem Ipsum",
"DATE": "14 June 2019",
"COUNTRY": "Poland"
},
{
"ID": 2,
"PUBLISHED": false,
"NAME": "Lorem Ipsum",
"TITLE": "Lorem Ipsum",
"SOURCE": "Lorem Ipsum",
"DATE": "05 August 2019",
"COUNTRY": "USA"
}
]
Basically, just after deploy, I get a link, but it contains data only from one sheet to which I provided the ID. The expected result should look like this:
- URL: ../macros/s/../exec/data-2018
- URL: ../macros/s/../exec/data-2019
- URL: ../macros/s/../exec/data-2020