title: Python requests application/x-www-form-urlencoded non json body
body: <p>I am trying to hit an API endpoint using python requests. I have been unable to successfully send the body of the request except when using cURL. Here is the cURL command that succeeds:</p>
  <pre><code>curl --location --request POST '&lt;api endpoint url&gt;' \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --data-urlencode 'obj={&quot;login&quot;:&quot;&lt;email&gt;&quot;,&quot;pword&quot;:&quot;&lt;password&gt;&quot;}'
  </code></pre>
  <p>Using python requests like this returns an error from the API because of the body of the request:</p>
  <pre><code>payload = 'obj={&quot;login&quot;:&quot;&lt;email&gt;&quot;,&quot;pword&quot;:&quot;&lt;password&gt;&quot;}'
  headers = {
      'Content-Type': 'application/x-www-form-urlencoded'
  }
  response = requests.post(url, headers=headers, data=payload)
  print(response.text)
  </code></pre>
  <p>I also tried <code>requests.request(&quot;POST&quot;)</code> but got the same results.</p>