Sometimes, we want to execute a script in a shell, post a piece of json data in a loop, and the field name and value in the body can be a variable. What should we do?
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}'
Reference link: http://stackoverflow.com/questions/17029902/using-curl-post-with-variables-defined-in-bash-script-functions