【问题标题】:How to send postman GET request using file url如何使用文件 url 发送邮递员 GET 请求
【发布时间】:2016-04-03 02:21:17
【问题描述】:

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

file:///absolute/path/to/file.txt

请求在任何浏览器中都能正常工作,但 postman 失败并显示消息:

无法得到任何回应

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

有什么方法可以让postman 使用文件 URI?

【问题讨论】:

    标签: postman file-uri


    【解决方案1】:

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

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

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

    然后你可以访问

    http://localhost:1234/filename
    

    这将提供文件。

    【讨论】:

      【解决方案2】:

      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

      一切都按预期进行。

      【讨论】:

        猜你喜欢
        • 2021-08-15
        • 1970-01-01
        • 2018-10-16
        • 1970-01-01
        • 2019-01-07
        • 2019-10-12
        • 1970-01-01
        • 2021-11-07
        • 2020-12-11
        相关资源
        最近更新 更多