繁体   English   中英

如何在cURL上的URL开头绑定变量,它会抛出错误

[英]How to bind a variable at the start of URL on cURL, it is throwing error

curl \ -H "Content-Type: application/json" \ -X POST \ $REPOSITORY_URL/engine-rest

http://10.195.177.141:31406绑定到REPOSITORY_URL

curl: no URL specified! curl: try 'curl --help' or 'curl --manual' for more information

我也试过给双引号

TL; DR:删除\\并再试一次。

尝试这个:

curl  -H "Content-Type: application/json"  -X POST  $REPOSITORY_URL/engine-rest

对我来说,似乎命令行中的\\字符是多余的。 他们告诉bash将空间视为参数值的一部分而不是分隔符。 考虑到这一点,你要传递给curl的第一个参数是“-H”(即:space:-H)。 由于此参数不以-开头,因此程序假定它是URL。 curl在-H上执行DNS查找,但无法解析该主机名:

curl: (6) Could not resolve host:  -H

我怀疑为什么我有一个不同的错误,因为我在MacOS上使用curl。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM