I am trying to create a script to call restapi endpoint but I am getting "bad substitution" error.
Here is my script:
vi script.sh
echo "welcome to the script"
echo ${"http://web-integ000/sampleProject/getProductList"}
but when I execute the curl command at commandline it worked.I used the following command
$ curl -H "Accept:application/json" http://web-integ000/sampleProject/getProductList
and I got the following output:
[ {
"productId" : "u1604028-5948abd0-0",
"prodcutName":"H1ACX",
"calendarDate" : "2017-06-20"
}
]timeStamp:1497968810
How to get the response from the restapi using script?
You can use a simple curl command to get the response from the server as follows:-
rest.sh
result=$(curl -X GET --header "Accept: */*" "http://localhost:9090/employees")
echo "Response from server"
echo $result
exit
Hope it works! Thanks!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With