title: Javascript Query.setQuery() to Google sheets using the Google visualization API gives 'Missing query for request id: undefined"
body: <p>I'm using the JavaScript Google visualization API to query tables of a spreadsheet. This works fine if I don't specify a specific query (or use 'select *'), but on using Query.setQuery('select ...') the requestId seems to get lost:</p>
  
  <blockquote>
    <p>Uncaught Error: Missing query for request id: undefined</p>
  </blockquote>
  
  <p>Code:</p>
  
  <pre><code>    // Load the Visualization API and the piechart package.
  google.load('visualization', '1.0', {'packages':['corechart']});
  
  // Set a callback to run when the Google Visualization API is loaded.
  google.setOnLoadCallback(queryTable);
  
  function queryTable() {
      var query = new google.visualization.Query(
        'https://docs.google.com/spreadsheets/d/129uqCEZksVwOSlqTYF7HVrnbOqD3HqPq-warEMvdur8/edit#gid=0');
      query.setQuery('select Date, Time, Name, Type, Preference'); // remove this line and it works
      query.send(handleQueryResponse);
  }
  
  
  function handleQueryResponse(response) {
      if (response.isError()) {
         alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
         return;
      }
  
      var data = response.getDataTable();
      var numrows = data.getNumberOfRows();
      var tableHtml = '&lt;table width="320"&gt;';
  
      for (var row=0; row &lt; numrows; row++) {
  
          var date = data.getValue(row, 0);
          var time = data.getValue(row, 1);
          var name = data.getValue(row, 2);
          var type = data.getValue(row, 3);
          var pref = data.getValue(row, 4);
  
          tableHtml += '&lt;tr&gt;&lt;td&gt;' + name + '&lt;/td&gt;&lt;td&gt;' + type + '&lt;/td&gt;&lt;td&gt;' + pref + '&lt;/td&gt;';
      }
      tableHtml += '&lt;/table&gt;';
      $('#table').append(tableHtml);
  }
  </code></pre>
  
  <p>The test spreadsheet is viewable here:
  <a href="https://docs.google.com/spreadsheets/d/129uqCEZksVwOSlqTYF7HVrnbOqD3HqPq-warEMvdur8/edit?usp=sharing" rel="nofollow">https://docs.google.com/spreadsheets/d/129uqCEZksVwOSlqTYF7HVrnbOqD3HqPq-warEMvdur8/edit?usp=sharing</a></p>
  
  <p>Sorry if this is a Noob question but can't seem to find a solution.
  Thanks</p>