title: how to run a function in my google app script via api using javascript
body: <p>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. </p>
  
  <p>I tried to send an api request as this
  target script code.gs</p>
  
  <pre><code> function addtext(sheetId) {
     var ss = SpreadsheetApp.openById(sheetId);
     ss.appendRow(['test', 'blabla'])
     });
   }
  </code></pre>
  
  <p>and javascript as this
       var scriptId = "";</p>
  
  <pre><code> // Initialize parameters for function call.
   var sheetId = "&lt;ENTER_ID_OF_SPREADSHEET_TO_EXAMINE_HERE&gt;";
  
   // 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
     });
   }
  </code></pre>