How to execute curl with json inside unix script by properly balancing brace/bracket

59 Views Asked by At

Ho to assign variables to curl which has a json format. Echo the curl command and then execute.

The actual command I am trying to execute inside the script as below

curl --location 'url' --header "Content-Type: application/json" --data '{"body": {"instruction":"START"}}'

The code snippet in the script is as below

iterationid=12345
domain_name=abcd
service=xyz
api_to_trigger="http://$domain_name/system/services/$service"
curl="curl --location '$api_to_trigger' --header \"Content-Type: application/json\" --data '{\"body\": {\"instruction\":\"START\"}}'"

echo $iterationid $curl
output=$($curl)
echo $iterationid $output

The mandatory requirement is to print the fully formed curl command along with the iteration id and also print the fully output of curl along with iteration id.

When i execute the script i get

curl: (3) [globbing] unmatched close brace/bracket at pos 24
0

There are 0 best solutions below