title: Create only one spreadsheet for storing data in doPost, without duplication
body: <p>I am using Google App Script to add data to a spreadsheet from an external source that POSTs to the script. I want to create the spreadsheet if it has not been created already and then append the data to the same spreadsheet. However, every time the external source POSTs, the script duplicates the spreadsheet and I get hundreds of files created in my Drive. </p>
  
  <p>I've tried checking if the spreadsheet is active and not null but as I am a total beginner I'm not really sure what I am doing and can't figure out how to make the script identify the created spreadsheet and not duplicate itself. </p>
  
  <pre><code>function doPost(e)
  {
  var sl = e.parameter;
  url = PropertiesService.getScriptProperties().getProperty('url');
  
   var payload =
     {
       "List":sl
  
  
     };
  
  
  
     var options =
     {
       "method" : "post",
       "payload" : payload
     };
  var response = UrlFetchApp.fetch(url,options);
  
  if(SpreadsheetApp.getActive() != null) 
  {
  
     //append data
  }
  
  else
  {
  
    var ssNew = SpreadsheetApp.create("Finances");
    var ssUrl = ssNew.getUrl();
    ssNew.setActiveSpreadSheet().openByUrl(ssUrl);
  
  }
  
  
  }
  </code></pre>
  
  <p>How do I create only one instance of the spreadsheet and add data to it?</p>