title: google drive spreadsheet script TypeError: Cannot call method "getDataRange" of null
body: <p>I have read that many people had the same problem as me but all the solutions given to them dont work neither for me nor for many others.</p>
  
  <p>When i deploy the script as a wep app and update it, as usual the following message appears:</p>
  
  <pre><code>Deploy as Web app
  ....
  current wep app url:
  ......
  Test web app for your "latest code" (link)
  </code></pre>
  
  <p>if i open the link given ("latest code") the web app works fine but if i open the url manually it says:</p>
  
  <pre><code>TypeError: Cannot call method "getDataRange" of null.
  </code></pre>
  
  <p>May be an authorize thing but im not sure.</p>
  
  <pre><code>var HEADER_SIZE=1;                                                   
  function myFunction() {
  
  var ss = SpreadsheetApp.openById('1_LpdPfvDnWCrFJ0NcbfTaUtQtsbD8Ph8xCNA-pTLuY0');
  var s = ss.getSheetByName('tablaSordos');
  var data  = s.getDataRange().getValues();                      
  var total =(data.length)-(HEADER_SIZE);                
  posicion donde termina el Header
  var il =  (total+HEADER_SIZE);                                      
  var users = [];                                                     
  
  for(i=sl; i&lt;il; i++){
  users.push(data[i]);                                           
   }                                                                 
  
  Logger.log(users);
  
  var usersData = [];
  
  for(i in users){
  
  var row           = users[i];
  var nombre        = row[0];
  var direccion     = row[1];
  var lat           = row[2];
  var long          = row[3];
  var territorio    = row[4];
  var localidad     = row[5];
  var observaciones = row[6];
  
  var userData= new toObject(nombre,direccion,lat, long, territorio, localidad, observaciones);    //creamos un objeto, con cada usuario
  Logger.log(userData);
  usersData[i] = userData;
  }
  
  return usersData;
  
  }
  
  function toObject(nombre, direccion, lat, long, territorio, localidad, observaciones){
  this.nombre = nombre;
  this.direccion = direccion;
  this.lat = lat;
  this.long = long;
  this.territorio = territorio;
  this.localidad = localidad;
  this.observaciones = observaciones;
   }
  
  function doGet() {
  var datos = myFunction();
  return ContentService.createTextOutput(JSON.stringify(datos)).setMimeType(ContentService.MimeType.JSON);
  }
  </code></pre>