0

I am trying to run a curl command in linux

curl -i -X POST -H 'Content-Type: application/json' -d '{"configuredLevel": "$LOGGINGLEVEL"}' ${i//$WORDTOREMOVE}

I wanted to insert the variable LOGGINGLEVEL in the payload but I am getting some error with this request.

When I change "$LOGGINGLEVEL" with some other value eg "INFO" I am not getting any errors

Is the correct method to insert a variable between two "

Biffen
  • 6,249
  • 6
  • 28
  • 36
  • Does this answer your question? [Expansion of variables inside single quotes in a command in Bash](https://stackoverflow.com/questions/13799789/expansion-of-variables-inside-single-quotes-in-a-command-in-bash) – Biffen Jun 15 '21 at 13:21
  • 1
    Use a tool like `jq` to generate JSON, to ensure any values in the variable are properly escaped. – chepner Jun 15 '21 at 13:24
  • Try this `-d '{"configuredLevel": '"$LOGGINGLEVEL"'}'` to connect your parameter. – Victor Lee Jul 03 '21 at 06:57

0 Answers0