Google apps script 尝试获取内容时UrlFetchApp.fetch正在中止执行
尝试使用任何可用方法收集响应内容时,此脚本将中止 调试时,我可以看到执行“getContentText()”会导致脚本中止 我尝试了mutehttpexceptions并遵循重定向。这个请求非常简单,完全可以用谷歌脚本实现Google apps script 尝试获取内容时UrlFetchApp.fetch正在中止执行,google-apps-script,Google Apps Script,尝试使用任何可用方法收集响应内容时,此脚本将中止 调试时,我可以看到执行“getContentText()”会导致脚本中止 我尝试了mutehttpexceptions并遵循重定向。这个请求非常简单,完全可以用谷歌脚本实现 var requestobj = { 'method' : 'post' }; var resp = UrlFetchApp.fetch("https://api.ghostinspector.com/v1/tests/5e20794bebbf452b12
var requestobj = {
'method' : 'post'
};
var resp = UrlFetchApp.fetch("https://api.ghostinspector.com/v1/tests/5e20794bebbf452b12be1714/export/selenium-html/?apiKey=xxx", requestobj);
var responseCode = resp.getResponseCode()
if (responseCode === 200) {
var responseJson = resp.getContentText();
}
```
哪里是
getContentText()
?您使用哪种类型的Google帐户运行此功能?能否发布您正在检索的响应(resp
variable)?您是否收到错误消息?如果有的话,请把它寄出去。对于我来说,正在使用另一个URL。如果在选项中不使用“muteHttpExceptions”:true
,则如果(responseCode==200){发生错误,则代码var responseCode=resp.getResponseCode(){
将永远不会运行。如果在获取调用中出现错误,并且您不使用“muteHttpExceptions”:true
在选项中,然后,如果代码中有try/catch,您的代码将停止,或者被try/catch拾取。因此,我总是使用“muteHttpExceptions”:true
在选项中。1)响应是一个html文件2)响应代码是200,因此在这方面没有问题3)没有引发其他错误,我尝试使用muteHttpExceptions,但由于没有错误,因此没有帮助4)在postman中启动相同的请求工作正常,正文中也有200个响应代码和xml。问题可以跟踪n在这里: