linux下curl如何发送get & post 带参数的请求

时间:2024-03-01 21:52:56

curl -v http://ip:port/service/name/op?param1=1\&param2=0\&param3="\[\{\"value\":1,\"value\":1\}\]"     能正常发送,但服务器端接收不到参数,原因大概是service只接受post请求
curl -v --globoff http://ip:port/service/name/op?param1=1\&param2=0\&param3="[{\"value\":1,\"value\":1}]"     同上,与上面的请求的区别是加了globoff,参数里面的括号不用转义

 

尝试用post方式发送:

curl http://ip:port/service/name/op -X POST -H "Content-type:application/json" -d \'{"param1":"16","param2":"0","param3":"[{\"value\":1,\"num\":1}]"}\'    能正常发送,但服务器仍然接收不到参数

curl http://ip:port/service/name/op -X POST -d \'param1=16&param2=0&param3=[{"value":1,"value":1}]\'     能正常发送,服务器端能正常获取参数