2012-11-22 74 views
2

我從以下功能的「意外的錯誤」:意外的錯誤谷歌Apps腳本獲取

function getBomgarFeedbackXML(){ 
    var url = "https://help.tradingtechnologies.com/api/reporting.ns?" + 
      "username=xxxxxx&password=xxxxxx&generate_report=SupportCustExitSurvey&" + 
      "start_date=2000-01-01&duration=0&report_type=rep&id=all"; 
    var response = UrlFetchApp.fetch(url).getContentText(); 
    Logger.log(response); 
    return(Xml.parse(response, true)); 
} 

導致錯誤的代碼行是:

var response = UrlFetchApp.fetch(url).getContentText(); 
  1. 我能取該URL以編程方式使用其他腳本語言,如python
  2. 我已經嘗試在我的瀏覽器中獲取URL,我可以成功地執行此操作
  3. 我可以從Google apps腳本中成功取得「http://www.google.com
  4. 在瀏覽到chrome中的URL時,我會收到以下警告,這可能與問題有關嗎?

warning message

任何幫助表示讚賞 感謝

回答

2

與不受信任的證書的最後一位是這裏的大線索。似乎與'help.tradingtechnologies.com'相關的SSL證書無效或由可信任的CA根據Google數據中心(UrlFetch調用的起源地址)簽名。

要解決此問題,請嘗試使用這一行代碼而不是UrlFetch調用。請注意0​​的附加選項記錄爲here

var response = UrlFetchApp.fetch(url, {'validateHttpsCertificates':false}).getContentText(); 
+0

優秀的,這個作品,非常感謝! – Sherlock