My current task involves accessing the Pingdom API using Google Apps Script, following this example provided: https://developers.google.com/apps-script/external_apis
query = 'credits';
var username = 'foo';
var password = 'bar';
var credentials = username+':'+password;
var url = 'https://'+credentials+'@api.pingdom.com/api/2.0/'+encodeURIComponent(query);
var headers = {
"App-Key": "abcd",
};
var options = {
"method": "get",
"headers": headers,
'validateHttpsCertificates':false
};
Logger.log(url);
var response = UrlFetchApp.fetch(url);
However, I encounter an error during code execution:
Unexpected error: https://foo:[email protected]/api/2.0/credits (line 17, file "Code") Dismiss
When I manually paste the URL above into a browser, it works fine (generating a "Missing application key" message from the Pingdom API, indicating that the username and password were correctly provided). I've tried with and without using encodeURIComponent
on credentials
, but the same error persists. Even adding 'muteHttpExceptions':true
does not resolve the issue.
Any insights on what might be causing this error?