title: Google apps script update fusion table from spreadsheet script
body: <p>I would like to create an apps script in a google docs spreadsheet that will periodically copy rows from the sheet and insert them into a fusion table. Below I've pasted my best attempt, but it should be noted that I really want it to be posting a 2 column range, not that pair of values. That is just a placeholder.</p>
  
  <p>This link here describes how to talk to fusion tables
  <a href="http://code.google.com/apis/fusiontables/docs/developers_guide.html#Inserting" rel="nofollow">http://code.google.com/apis/fusiontables/docs/developers_guide.html#Inserting</a> </p>
  
  <p>But I dont understand how to write the script to achieve this. I've messed around with it a bunch and I think I have these problems </p>
  
  <p>-I'm not forming the post request correctly
  -I'm missing some sort of authentication step.</p>
  
  <p>I am a total newb and what I have here is copy pasted. A few resources that looked helpful:</p>
  
  <p>This guy seems to have figured out how to write an app script to send post requests
  <a href="http://blog.vivekhaldar.com/post/428652690/google-apps-script-spreadsheets-mashup-hub" rel="nofollow">http://blog.vivekhaldar.com/post/428652690/google-apps-script-spreadsheets-mashup-hub</a> </p>
  
  <p>This seems to be important</p>
  
  <pre><code>http://code.google.com/googleapps/appsscript/class_urlfetchapp.html
  </code></pre>
  
  <p>these people seem to be doing somthing very similiar, but I cant figure out how to make it work</p>
  
  <pre><code>http://groups.google.com/group/fusion-tables-users-group/browse_thread/thread/99db4db33e405f01
  
  
  function deet() {
    var advancedArgs = {
        method: "post", 
        payload: "?sql=" + "INSERT INTO 1299801(Text, Number) VALUES ('Blue Shoes', 50)", 
        headers: {"Authorization": "Basic &lt;base64 encoding of your username:passwd"}};
    var response = UrlFetchApp.fetch(
        "https://www.google.com/fusiontables/api/query",advancedArgs);
  
  }
  </code></pre>
  
  <p>Thanks in advance!</p>