Curl not working when called with subprocess
<p>I'm trying to call a REST api with curl. The api endpoint is dynamically generated in the program and a json file is also uploaded.</p>

<pre><code>with open('data.json','w') as f:
    f.write(json.dumps(data))
    cmd = 'curl -X PUT -H "Content-Type: application/json" -d @data.json {0}'.format(put_uri)
    print cmd
    p= subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
    p.wait()
    output, errors = p.communicate()
    if p.returncode != 0:
        print "Request failed"
</code></pre>

<p>Here i'm printing the command formed and when i run that command from shell, it is working as it is intended to do. But the same command is run with Popen throws some json validation error which is weired </p>

<pre><code>{
  "success" : false,
  "message" : "Resource cannot be parsed due to Unexpected character ('/' (code 47)): maybe a (non-standard) comment? (not recognized as one since Feature 'ALLOW_COMMENTS' not enabled for parser)\n at [Source: java.io.StringReader@444c7495; line: 1, column: 2]"
}
</code></pre>