title: Python Requests module JSON format
body: <p>I have a Django application with tastypie set up for REST.</p>
  
  <p>I want to be able to update the database using the REST API. </p>
  
  <p>I can issue a curl command on the command line to achive what I want, (as per the tastypie documentation). </p>
  
  <pre><code>curl --dump-header - -H "Content-Type: application/json" -X PATCH --data '{"comments": "comment1"}' http://127.0.0.1:8000/api/seq/loadedwith/12092/
  
  HTTP/1.0 202 ACCEPTED
  Date: Fri, 26 Oct 2012 11:06:58 GMT
  Server: WSGIServer/0.1 Python/2.6.6
  Content-Type: text/html; charset=utf-8
  </code></pre>
  
  <p>So now I am trying to achieve the same thing using the requests module. Get requests work from the python requests module, but I can't get patch or posts to work. </p>
  
  <pre><code>url='http://127.0.0.1:8000/api/seq/loadedwith/12092/'
  headers={'content-type': 'application/json'}
  payload={"comments":"comment2"}
  requests.patch(url=url, params=json.dumps(payload),  headers=headers)
  </code></pre>
  
  <p>I get the error:</p>
  
  <pre><code>  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    File "/usr/local/lib/python2.7/dist-packages/requests-0.14.1-py2.7.egg/requests/api.py", line 120, in patch
        return request('patch', url,  data=data, **kwargs)
    File "/usr/local/lib/python2.7/dist-packages/requests-0.14.1-py2.7.egg/requests/safe_mode.py", line 39, in wrapped
        return function(method, url, **kwargs)
    File "/usr/local/lib/python2.7/dist-packages/requests-0.14.1-py2.7.egg/requests/api.py", line 51, in request
        return session.request(method=method, url=url, **kwargs)
    File "/usr/local/lib/python2.7/dist-packages/requests-0.14.1-py2.7.egg/requests/sessions.py", line 182, in request
      params=from_key_val_list(params),
    File "/usr/local/lib/python2.7/dist-packages/requests-0.14.1-py2.7.egg/requests/utils.py", line 135, in from_key_val_list
      raise ValueError('cannot encode objects that are not 2-tuples')
  ValueError: cannot encode objects that are not 2-tuples
  </code></pre>
  
  <p>This seems to be coming when I add the json.dumps(payload) - I tried passing just the dictionary, but the payload gets added to the querysting in that case, and tastypie complains. I have tried formatting the dictionary as a tuple , but I am not sure what it expects exactly. </p>
  
  <p>Can someone help, (or am I looking at the wrong place in the code)?</p>