title: Ant exec task using cURL to POST a JSON body doesn't work, identical command works manually in Windows command prompt
body: <p>I'm running this task as part of a larger target in an Ant script. It executes a command in the Windows command prompt and routes the output to a text file in the temp directory. I've changed the URL argument to protect sensitive information.</p>
  
  <pre><code>&lt;exec executable="cf.cmd" output="${java.io.tmpdir}/cmd_out.txt" failonerror="true" vmlauncher="false"&gt;
      &lt;arg value="curl" /&gt;
      &lt;arg value="POST" /&gt;
      &lt;arg value="http://www.google.com/v2/routes" /&gt;
      &lt;arg value="--body" /&gt;
      &lt;arg value="&amp;#39;{&amp;quot;host&amp;quot;: &amp;quot;${old.app.name}&amp;quot;, &amp;quot;domain_guid&amp;quot;: &amp;quot;${domain.guid}&amp;quot;, &amp;quot;space_guid&amp;quot;: &amp;quot;${space.guid}&amp;quot;}&amp;#39;" /&gt;
  &lt;/exec&gt;
  </code></pre>
  
  <p>From Ant's verbose logs, this task produces the following command:</p>
  
  <pre><code>Current OS is Windows 7
  [exec] Output redirected to C:\Users\foo\AppData\Local\Temp\cmd_out.txt
  [exec] Executing 'cf' with arguments:
  [exec] 'curl'
  [exec] 'POST'
  [exec] 'http://www.google.com/v2/routes'
  [exec] '--body'
  [exec] ''{"host": "foo", "domain_guid": "4cc4c9b0-5b87-40f5-8ecc-6d6347a3236d", "space_guid": "6c3338e2-422d-46c0-a901-eda41b1fd968"}''
  [exec] 
  [exec] The ' characters around the executable and arguments are
  [exec] not part of the command.
  </code></pre>
  
  <p>When run, this task produces the following output in cmd_out.txt:</p>
  
  <pre><code>{
    "code": 1001,
    "description": "Request invalid due to parse error: lexical error: invalid char in json text.\n                                      {host: foo, domain_guid\n                     (right here) ------^\n
    "error_code": "CF-MessageParseError
    "types": [
      "MessageParseError
      "Error"
    ],
    "backtrace": []
  }
  </code></pre>
  
  <p>However, if I execute this identical command manually in the Windows command prompt:</p>
  
  <pre><code>cf curl POST http://www.google.com/v2/routes --body '{"host": "foo", "domain_guid": "4cc4c9b0-5b87-40f5-8ecc-6d6347a3236d", "space_guid": "6c3338e2-422d-46c0-a901-eda41b1fd968"}'
  </code></pre>
  
  <p>Then I get the correct result. No point in posting it here, but it's a success message instead of an invalid parse error message.</p>
  
  <p>If I run this command in the manual Windows command prompt (notice the lack of single quotes around the JSON body), then I get the same error as the Ant script:</p>
  
  <pre><code>cf curl POST http://www.google.com/v2/routes --body {"host": "foo", "domain_guid": "4cc4c9b0-5b87-40f5-8ecc-6d6347a3236d", "space_guid": "6c3338e2-422d-46c0-a901-eda41b1fd968"}
  </code></pre>
  
  <p>I'm at a loss here. From what I can see, Ant is running the same command as what I am doing manually. Yet the Ant version fails, and the manual version succeeds. Can anyone see what I'm doing wrong?</p>