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

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

问题描述

我从以下函数中得到一个意外错误":

函数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(响应);返回(Xml.parse(响应,真));}

导致错误的行是:

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

  1. 我可以使用其他脚本语言(例如 python)以编程方式获取 URL
  2. 我已尝试在浏览器中获取 URL,但我成功了
  3. 我可以成功从 Google Apps 脚本中获取.

    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天全站免登陆