title: Making HTTP POST request using requests in Python
body: <p>I am trying to make a HTTP request to an API using the POST method. The API that I am using is meant to take in three parameters (key1, key2, key3) and return a json file. Unfortunately, my POST request does not seem to return anything when I am using the <strong>data</strong> method to pass my dictionary to the API. This seems to be very strange because it seems to work when I am using the <strong>params</strong> method. I cannot try to understand this as this process seems to be very opaque (e.g. I cannot a URL to see how the payload are passed onto the API). </p>
  
  <p>My question: What am I doing wrong here?</p>
  
  <p>POST request where the parameters are sent over to the API using <strong>data</strong> method:</p>
  
  <pre><code>import requests
  
  url = 'http://example.com/API.php'
  payload =  {
              'key1': '&lt;&lt;Contains very long json string&gt;&gt;', 
              'key2': 5, 
              'key3': 0
             }
  
  print len(str(payload)) # Prints 6717
  r = requests.post(url, data=payload) &lt;&lt; Note data is used here
  print r.status_code # Prints 200
  print r.text # Prints empty string
  </code></pre>
  
  <p>POST request code where the parameters are sent over to the API using the <strong>params</strong> method:</p>
  
  <pre><code>import requests
  
  url = 'http://example.com/API.php'
  payload =  {
              'key1': '&lt;&lt;Contains very long json string&gt;&gt;', 
              'key2': 5, 
              'key3': 0
             }
  
  print len(str(payload)) # Prints 6717
  r = requests.post(url, params=payload) &lt;&lt; Note here params is used here
  print r.status_code # Prints 200
  print r.text # Prints expected JSON results
  </code></pre>
  
  <p>If you are wondering why I would like to use the <strong>data</strong> method over <strong>params</strong>... I am trying to pass other dictionaries containing longer strings and the <strong>params</strong> method does not seem to do it because I am getting <em>ERROR 414</em>. I was hoping that the error could be resolved by using <strong>data</strong>.</p>
  
  <p>The API that I am using was written in PHP. </p>