title: Python requests module: urlencoding json data
body: <p>I'm working on an API wrapper. The spec I'm trying to build to has the following request in it:</p>
  
  <pre><code>curl -H "Content-type:application/json" -X POST -d data='{"name":"Partner13", "email":"example@example.com"}' http://localhost:5000/
  </code></pre>
  
  <p>This request produces the following response from a little test server I setup to see exatly what headers/params etc are sent as. This little script produces:</p>
  
  <pre><code>uri: http://localhost:5000/,
  method: POST,
  api_key: None,
  content_type: application/json,
  params: None,
  data: data={"name":"Partner13", "email":"example@example.com"}
  </code></pre>
  
  <p>So that above is the result I want my python script to create when it hits the little test script.</p>
  
  <p>I'm using the python requests module, which is the most beautiful HTTP lib I have ever used. So here is my python code:</p>
  
  <pre><code>uri = "http://localhost:5000/"
  headers = {'content-type': 'application/json' }
  params = {}
  data = {"name":"Partner13", "email":"example@exmaple.com"}
  params["data"] = json.dumps(data)
  r = requests.post(uri, data=params, headers=headers)
  </code></pre>
  
  <p>So simple enough stuff. Set the headers, and create a dictionary for the POST parameters. That dictionary has one entry called "data" which is the JSON string of the data I want to send to the server. Then I call the post. However, the result my little test script gives back is:</p>
  
  <pre><code>uri: http://localhost:5000/,
  method: POST,
  api_key: None,
  content_type: application/json,
  params: None,
  data: data=%7B%22name%22%3A+%22Partner13%22%2C+%22email%22%3A+%22example%40example.com%22%7D
  </code></pre>
  
  <p>So essentially the json data I wanted to send under the data parameter has been urlendcoded.</p>
  
  <p>Does anyone know how to fix this? I have looked through the requests documentation and cannot seem to find a way to not auto urlencode the send data. </p>
  
  <p>Thanks very much,
  Kevin</p>