How to pass Parameters in Ruby for Google App Script
<p>I have the following script in Google Apps:</p>

<pre><code>function createSpreadsheet(environment, timestamp) { 
  Logger.log(environment);
  var folders = DriveApp.getFoldersByName(environment); 
  while (folders.hasNext()) {
   var folder = folders.next();
  }  

  var testName = timestamp + ".test_" + environment;
  Logger.log(testName);

  var file = {
    "title": testName,
    "mimeType": "application/vnd.google-apps.spreadsheet",
    "parents": [
      {
        "id": folder.getId()
      }
    ] 
  };

  Drive.Files.insert(file);
  var allFiles = folder.getFilesByName(testName);
  var files = {};
  while (allFiles.hasNext()) {
   var file = allFiles.next();
   return file.getId();
  } 

}
</code></pre>

<p>and from Ruby code I am performing the following call</p>

<pre><code>request = Google::Apis::ScriptV1::ExecutionRequest.new
    request.function = 'createSpreadsheet'
    request.parameters = [environment.to_s ,timestamp.to_s ]
</code></pre>

<p>But it is not working and I get error during the execution of the script:</p>

<pre><code>Script error message: Cannot call method "getId" of undefined.
</code></pre>

<p>What I am doing wrong ? that parameters are a simple strings </p>

<p>Thanks a lot </p>