小编Rx2*_*000的帖子

UrlFetchApp 无法访问本地主机资源

这工作正常:

var resp = UrlFetchApp.fetch("someremotehost/SomeFile.csv");
resp.getResponseCode();  //returns 200
resp.getContentText();   //returns the data
Run Code Online (Sandbox Code Playgroud)

但是,在我的本地计算机上,我正在运行 xampp,SomeFile.csv 位于 htdocs/dev 中,但我无法让它在本地主机上工作:

var resp = UrlFetchApp.fetch("localhost/dev/SomeFile.csv");
resp.getResponseCode(); //returns 0.0
resp.getContentText()   //returns nothing!
Run Code Online (Sandbox Code Playgroud)

我检查了 chrome-extension postman 并且http://localhost/dev/SomeFile.csv工作正常,那么为什么不起作用呢UrlFetchApp.fetch("http://localhost/dev/SomeFile.csv")

localhost urlfetch google-apps-script

4
推荐指数
1
解决办法
6388
查看次数

标签 统计

google-apps-script ×1

localhost ×1

urlfetch ×1