title: Google Apps Script and External API
body: <p>If I am not mistaken, as per <a href="https://developers.google.com/apps-script/class_urlfetchapp">UrlFetch Documentation</a> I should be able to call the <a href="https://github.com/37signals/bcx-api/">New Basecamp API</a> from within Google Apps Script. I suspect my confusion comes from a formatting GAS mistake (and the fact that I am just beginning all this). I have googled this a long while. This is what I have and the error I get back from GAS:</p>
  
  <p>myCode in GAS:</p>
  
  <pre><code>function myFunction() {
    var url = "https://basecamp.com/******/api/v1/projects.json";
    var headers = {
                   "contentType": "application/json",
                   "headers":{ "User-Agent": "MY_APP_NAME",
                              "username:password" : "user:pass"},
                   "validateHttpsCertificates" :false
                   };
  
  var response = UrlFetchApp.fetch(url, headers);
  var text = response.getResponseCode();
  Logger.log(text);
  }
  </code></pre>
  
  <p>GAS Error Message:</p>
  
  <pre><code>Request failed for https://basecamp.com/2166446/api/v1/projects.json returned code 401.
  Server response: HTTP Basic: Access denied. (line 9, file "Code")
  </code></pre>
  
  <p>I hope this is a reasonable question and thank you for the help. </p>