I want to run a function in my google app script file. but how can i run it via api in an external website. Help anyone please.
I tried to send an api request as this target script code.gs
function addtext(sheetId) {
var ss = SpreadsheetApp.openById(sheetId);
ss.appendRow(['test', 'blabla'])
});
}
and javascript as this var scriptId = "";
// Initialize parameters for function call.
var sheetId = "<ENTER_ID_OF_SPREADSHEET_TO_EXAMINE_HERE>";
// Create execution request.
var request = {
'function': 'addtext',
'parameters': [sheetId],
'devMode': true
};
// Make the request.
function apire() {
gapi.client.request({
'root': 'https://script.googleapis.com',
'path': 'v1/scripts/' + scriptId + ':run',
'method': 'POST',
'body': request
});
}