意外错误Google Apps脚本抓取 [英] Unexpected Error Google Apps Script Fetch

查看:117
本文介绍了意外错误Google Apps脚本抓取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  function getBomgarFeedbackXML(){
var url =https://help.tradingtechnologies.com/api/reporting.ns? +
用户名= xxxxxx&密码= 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 as python

  2. 我已经尝试在浏览器中获取我能够成功完成的URL

  3. 我可以获取。

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


    I get an "Unexpected Error" from the following function:

    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));
    }
    

    The line that causes the error is:

    var response = UrlFetchApp.fetch(url).getContentText();
    

    1. I am able to fetch the URL programatically using other scripting languages, such as python
    2. I have tried fetching the URL in my browser which I was able to do successfully
    3. I can fetch "http://www.google.com" from Google apps script successfully
    4. I get the following warning when navigating to the URL in chrome, could this be related to the issue ?

    Any help is appreciated Thanks

    解决方案

    The last bit with the untrusted certs is the big clue here. Seems like the SSL cert associated with 'help.tradingtechnologies.com'is not valid or signed by a trusted CA per the Google Data Centers (from where the UrlFetch calls originate).

    To work around this try this line of code instead of your UrlFetch call. Note the additional option for validateHttpsCertificates documented here.

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

    这篇关于意外错误Google Apps脚本抓取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆