如何使用文件URL发送邮递员GET请求

时间:2015-12-29 08:04:56

标签: postman file-uri

我正在尝试使用postman通过file URI scheme发送GET请求。一个例子:

$f = new \Illuminate\Support\Fluent; $f->something('value')->willBeTrue(); dump($f); // Illuminate\Support\Fluent { #attributes: array:2 [ "something" => "value" "willBeTrue" => true ] }

请求在任何浏览器中都能正常运行,但println (new Date())失败并显示消息:

  

无法获得任何回复

     

这似乎是连接到 file:///absolute/path/to/file.txt

的错误

有没有办法让postman使用文件URI?

2 个答案:

答案 0 :(得分:1)

Postman不支持文件URI,因为Chrome App平台不允许直接访问文件。

自己启动一个小型HTTP服务器应该很容易..如果您使用的是Mac / Linux,则可以使用Python在目录中提供文件:

$ cd /path/to/directory/
$ python -m SimpleHTTPServer 1234

然后您可以访问

http://localhost:1234/filename

将提供文件。

答案 1 :(得分:0)

Good answer

我不熟悉SimpleHTTPServer,所以我使用了live-server

  1. 我按照 2. Install and Run a Local Web Server 上的说明安装了 live-server

  2. 那么:

    cd /path/to/(myJSONfile.json)
    live-server <myJSONfile.json>

并且 JSON 文件是在我的默认网络浏览器中打开的。

  1. 最后,在 Postman 中,我发出了一个正常的 GET 请求,但是在地址上 http://127.0.0.1:8080

一切都按预期进行。

相关问题