0

Can's seem to get a variable to expand within a cURL option.

I've tried various approaches including the following:

curl -X POST http://localhost:9047/api/v3/sql \
-H 'Authorization: ${mytoken} ' \

curl -X POST http://localhost:9047/api/v3/sql \
-H 'Authorization: "'"$mytoken"'" ' \

Appreciate any suggestions.

  • you need to wrap the WHOLE string in double quotes in stead of single quote: `"Authorization: ${mytoken}"`. You seem to have the right idea in the second example, but since it is inside the outer string literal bash does not treat it as an expansion – joshmeranda Aug 07 '21 at 06:07
  • 2
    See: [Difference between single and double quotes in bash](http://stackoverflow.com/q/6697753/3776858) – Cyrus Aug 07 '21 at 07:08
  • Thanks Josh, that worked like a champ! Cyrus, appreciate you providing that link -- that was the best thread I've seen explaining the differences between single and double quotes. – Lew Goldstein Aug 08 '21 at 15:41

0 Answers0