title: How do I read a response from Python Requests?
body: <p>I have two Python scripts. One uses the <a href="https://docs.python.org/2/library/urllib2.html" rel="noreferrer">Urllib2 library</a> and one uses the <a href="http://docs.python-requests.org/" rel="noreferrer">Requests library</a>.</p>
  
  <p>I have found Requests easier to implement, but I can't find an equivalent for urlib2's <code>read()</code> function. For example:</p>
  
  <pre><code>...
  response = url.urlopen(req)
  print response.geturl()
  print response.getcode()
  data = response.read()
  print data
  </code></pre>
  
  <p>Once I have built up my post url, <code>data = response.read()</code> gives me the content - I am trying to connect to a vcloud director api instance and the response shows the endpoints that I have access to. However if I use the Requests library as follows.....</p>
  
  <pre><code>....
  
  def post_call(username, org, password, key, secret):
  
      endpoint = '&lt;URL ENDPOINT&gt;'
      post_url = endpoint + 'sessions'
      get_url = endpoint + 'org'
      headers = {'Accept':'application/*+xml;version=5.1', \
                 'Authorization':'Basic  '+ base64.b64encode(username + "@" + org + ":" + password), \
                 'x-id-sec':base64.b64encode(key + ":" + secret)}
      print headers
      post_call = requests.post(post_url, data=None, headers = headers)
      print post_call, "POST call"
      print post_call.text, "TEXT"
      print post_call.content, "CONTENT"
      post_call.status_code, "STATUS CODE"
  
  ....
  </code></pre>
  
  <p>....the <code>print post_call.text</code> and <code>print post_call.content</code> returns nothing, even though the status code equals 200 in the requests post call.</p>
  
  <p>Why isn't my response from Requests returning any text or content?</p>