如何在shell中curl一个带变量的post请求


有时候,我们想在一个shell中,执行一段脚本,循环post一段json数据,而且body里面的字段名和值都可以是一个变量应该怎么做?


test.sh
id=1111
name="ct"
curl http://192.1.13.100:8888/dataservice/knowledge/createKP  -H "Accept: application/json"  -H "Content-Type: application/json"  -d '{"kpId":"'"$id"'","kpName":"'"$name"'","description":"desc","path":"0-1-","sort":1,"version":1,"parentKPId":
1}'  


参考链接: http://stackoverflow.com/questions/17029902/using-curl-post-with-variables-defined-in-bash-script-functions

猜你喜欢

转载自qindongliang.iteye.com/blog/2335329