title: python-requests equivalent to curl's --data-binary?
body: <p>Curl has an option to send a file as is with the <a href="http://curl.haxx.se/docs/manpage.html#--data-binary" rel="noreferrer">--data-binary option</a>.</p>
  
  <p>When testing the <a href="http://www.qualys.com/docs/WAS_API_User_Guide.pdf" rel="noreferrer">Qualys WAS API</a>, the following curl command works:</p>
  
  <pre><code>curl -u "username:password" -H "content-type: text/xml" -X "POST" --data-binary @- "https://qualysapi.qualys.com/qps/rest/3.0/search/was/webapp" &lt; post.xml
  </code></pre>
  
  <p>post.xml:</p>
  
  <pre><code>&lt;ServiceRequest&gt;&lt;filters&gt;&lt;Criteria operator="CONTAINS" field="name"&gt;PB - &lt;/Criteria&gt;&lt;/filters&gt;&lt;/ServiceRequest&gt;
  </code></pre>
  
  <p>Using Python's requests module, I keep receiving a HTTPError: 415 Client Error: Unsupported Media Type.</p>
  
  <pre><code>import requests
  url = 'https://qualysapi.qualys.com/qps/rest/3.0/search/was/webapp'
  payload = '&lt;ServiceRequest&gt;&lt;filters&gt;&lt;Criteria operator="CONTAINS" field="name"&gt;PB - &lt;/Criteria&gt;&lt;/filters&gt;&lt;/ServiceRequest&gt;'
  headers = {'X-Requested-With': 'Python requests', 'Content-type': 'application/json'}
  r = requests.post(url, data=payload, headers=headers, auth=('username', 'password'))
  </code></pre>
  
  <p>When trying to submit file files parameter, it also ended in a 415 error.</p>
  
  <pre><code>import requests
  url = 'https://qualysapi.qualys.com/qps/rest/3.0/search/was/webapp'
  payload = '&lt;ServiceRequest&gt;&lt;filters&gt;&lt;Criteria operator="CONTAINS" field="name"&gt;PB - &lt;/Criteria&gt;&lt;/filters&gt;&lt;/ServiceRequest&gt;'
  headers = {'X-Requested-With': 'Python requests', 'Content-type': 'application/json'}
  r = requests.post(url, data=payload, headers=headers, auth=('username', 'password'))
  </code></pre>
  
  <p>The reason I'm setting this up is to incorporate this into the <a href="https://github.com/paragbaxi/qualysapi/" rel="noreferrer">qualysapi Python package</a>.</p>