I want to know if I'm missing something. I am using google's sample code from their Documentation:
var username = "myUserName";
var password = "myPsw";
var url = "http://myurl.com/ReportServer?/ExternalData/SCCOfficeHuddleCount&rs:Format=CSV";
var authHeader = 'Basic ' + Utilities.base64Encode(username + ':' + password);
var options = {
headers: {Authorization: authHeader}
}
var response = UrlFetchApp.fetch(url, options);
but still getting 401 - unauthorized. I don't know if I'm missing something.
I already validate that the URL is working. If I paste this URL below in the browser directly
http://user:[email protected]/ReportServer?/ExternalData/SCCOfficeHuddleCount&rs:Format=CSV
I get the CSV file. So how can I do this using AppScript?
UrlFetchApp.fetch('http://user:[email protected]/ReportServer?/ExternalData/SCCOfficeHuddleCount&rs:Format=CSV')
encodeURI(url)
before fetching (in both your existing code, and in my previous suggestion), in case there are special characters in the url that need to be escaped.