【发布时间】:2021-01-14 18:38:41
【问题描述】:
我有一个 Web API,当我使用 Postman 向它发送 get 请求时它工作正常。例如,API 可以处理这个请求:
http://localhost:5000/api/test/?id=23
当我用 curl ($ curl http://localhost:5000/api/test/?id=23) 尝试同样的事情时,我得到了这个错误:
curl: (3) URL using bad/illegal format or missing URL
这里有什么问题?
【问题讨论】:
-
尝试通过 Postman 的代码功能导出 curl。也许您在 Postman 中的请求中有标头,而您没有在 curl 中发送这些标头。
-
@ChristianBaumann 谢谢,我该怎么做?我在 Postman 中看到 Import,但没有看到 Export。
-
我刚刚运行了你的 curl 语句 (
curl http://localhost:5000/api/test/?id=23) 并得到了curl: (7) Failed to connect to localhost port 5000: Connection refused,因为我没有在端口上运行任何东西......语句应该没问题