How to pass a header as argument in curl command?
<p>I am attempting to do a curl command that uses a predefined variable as a header.</p>

<pre><code>header='-H "Content-Type: application/json" -H "userGUID: 7feb6e62-35da-4def-88e9-376e788ffd97" -H "Content-Length: 51"'
</code></pre>

<p>And this is essentially the curl command</p>

<pre><code>curl $header -w "http code: %{http_code}\\n" -X POST -d $BODY $URL 
</code></pre>

<p>Which then returns the error message </p>

<pre><code>rl: (6) Could not resolve host: application
curl: (6) Could not resolve host: 7feb6e62-35da-4def-88e9-376e788ffd97"
curl: (6) Could not resolve host: 51"
</code></pre>

<p>This works as expected</p>

<pre><code>curl -H "Content-Type: application/json" -H "userGUID: 7feb6e62-35da-4def-88e9-376e788ffd97" -H "Content-Length: 51" -w "http code: %{http_code}\\n" -X POST -d $BODY $URL 
</code></pre>

<p>The reason I'm trying to pass the header as a variable is because I'm writing a script that loops through and array, but currently this does not work with headers for some reason. There is no issue passing arguments for body.</p>