先看例子
curl -H "Content-Type:application/json"
-X POST
-d "{\"value\":\"type=username&username=xxxx0001\"}"
http://127.0.0.1:8111/loginbyother
//以上命令是为了方便看代码而换行,实际是一整行
在Windows Terminal中执行上面的语句,会一直报错
curl: no URL specified!
curl: try 'curl --help' for more information
一直以为是引号的问题,于是换各种方式对引号进行转义,甚至还用上UrlEncode方式,但都没效果,最终确定,是 & 号的问题,因为在windows中,&表示指令连接,所以必须进行转义。
& 转义 ====> ^&
于是修改代码如下
curl -H "Content-Type:application/json"
-X POST
-d "{\"value\":\"type=username^&username=xxxx0001\"}"
http://127.0.0.1:8111/loginbyother
//以上命令是为了方便看代码而换行,实际是一整行
bat文件中也会经常遇到这种问题,吃一堑长一智~