I am trying to retrieve a documents body via the REST API with Python, but am unable to actually get a response back. Here is a snippet of my code:

header = {'Authorization': 'Bearer ' + self.sf_connection.access_token,
          'content-type': 'application/json'
response = requests.get(url=self.base_url + "/" + record_id + '/Body', stream=False, headers=header)
print "Headers: %s" % response.headers
print "B text: %s" % response.text
print "B content: %s" % response.content
print "B raw: %s" % response.raw
print "B raw: %s" % response.raw.data
print "B raw: %s" % response.raw.read(10)

the response of print/debug statements is:

Headers: {'date': 'Mon, 27 Jun 2016 19:18:01 GMT', 'transfer-encoding': 'chunked', 'content-type': 'application/octetstream', 'sforce-limit-info': 'api-usage=200/15000'}
B text: 
B content: 
B raw: <requests.packages.urllib3.response.HTTPResponse object at 0x1105852d0>
B raw: 
B raw: 

I am thinking it was an issue with the content-type but still have not been avle to crack this. Any help is much appreciated!





  • I received the same results as above. – tauren.kristich Jun 27 '16 at 20:00
  • Did you include 'Authorization' header in your headers? – prashanthkr Jun 27 '16 at 21:03
  • I've updated my code snippet to include my headers - but yes i have the authorization in my headers with the token – tauren.kristich Jun 27 '16 at 21:20
  • Try printing the JSON response and you will see the real issue. I suspect it is due to Salesforce disabling TLS 1.0 in all sandboxes on June 25. – prashanthkr Jun 27 '16 at 23:17
  • I have all ready solved the TLS support issue. When i try to print the response.json() I get this error: "ValueError: No JSON object could be decoded" – tauren.kristich Jun 28 '16 at 13:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.