这工作正常:
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")?