title: Why is this bash/CURL call to REST services giving inconsistent results with parameters?
body: <p>I have written a smoke-testing script that uses BASH script &amp; Curl to test RESTful web services we're working on.  The script reads a file, and interprets each line as a URL suffix and parameters for a Curl REST call. </p>
  
  <p><strong>Unfortunately, the script gives unexpected results</strong> when I adapted it to run HTTP POST calls as well as GET calls.  It does not give the same results running the command on its own, vs. in script:</p>
  
  <p><strong>The BASH Script:</strong></p>
  
  <pre><code>IFS=$'\n' #Don't split an input URL line at spaces
  RESTHOST='hostNameAndPath' #Can't give this out
  
  URL="/activation/v2/activationInfo --header 'Content-Type:Application/xml'"
  URL2="/activation/v2/activationInfo"
  
  OUTPUT=`curl -sL -m 30 -w "%{http_code}" -o /dev/null $RESTHOST$URL -d @"./activation_post.txt" -X POST`
  echo 'out:' $OUTPUT
  
  OUTPUT2=`curl -sL -m 30 -w "%{http_code}" -o /dev/null $RESTHOST$URL2 --header 'Content-Type:Application/xml' -d @'./activation_post.txt' -X POST`
  echo 'out2:' $OUTPUT2
  </code></pre>
  
  <p><strong>Results Out:</strong></p>
  
  <blockquote>
    <p>out: 505<br>
    out2: 200</p>
  </blockquote>
  
  <p>So, <strong>the first call fails</strong> (HTTP return code 505, HTTP Version Not Supported), and the <strong>second call succeeds</strong> (return code "OK").</p>
  
  <p><strong>Why does the first call fail, and how do I fix it?</strong>  I've verified they should execute the same command (evaluating in echo).  I am sure there is something basic I'm missing, as I am just NOW learning Bash scripting.</p>