Converting url encode data from curl to json object in python using requests
<p>What is the best way to convert the below curl post into python request using the requests module:</p>

<pre><code>curl -X POST https://api.google.com/gmail --data-urlencode json='{"user": [{"message":"abc123", "subject":"helloworld"}]}'
</code></pre>

<p>I tried using python requests as below, but it didn't work: </p>

<pre><code>payload = {"user": [{"message":"abc123", "subject":"helloworld"}]}
url = https://api.google.com/gmail
requests.post(url, data=json.dumps(payload),auth=(user, password))
</code></pre>

<p>Can anybody help. </p>

<p>As the comment mentioned, you should put your <code>url</code> variable string in quotes <code>""</code> first.</p>

<p>Otherwise, your question is not clear. What errors are being thrown and/or behavior is happening?</p>

<p><a href="http://stackoverflow.com/questions/17936555/how-to-construct-the-curl-command-from-python-requests-module"> New cURL method in Python </a></p>

python http-post python-requests