0

tl;dr - How can one access the returned data from a callout to a ContentVersion.VersionData field value (sObject blob) in Python?

Background

As a follow up to this question's reply, I currently have a python script that makes an API call similar to the example below. The call is successful, but the response does not have a body and the response.text is a massive file with many missing ascii keys.

Call example: /services/data/v58.0/sobjects/ContentVersion/069XXXXXXXXXXXXX/VersionData

Response:

enter image description here

The salesforce documentation on sObject blob data states that the content is returned in binary form, but my attempts to convert from binary to other forms have failed.

Question

How can I convert/decode the returned sObject blob data into a usable data type?

2
  • all those diamond-? values indicate a non-UTF-8 character and hence the Blob can't be decoded into anything but must be used as is
    – cropredy
    Commented Aug 16, 2023 at 0:10
  • @cropredy that makes sense, but I wonder if that's a result of using r.text as opposed to some other property. Maybe that's the only way to access the data but I'm wondering if there's another way.
    – Jwok
    Commented Aug 16, 2023 at 15:46

1 Answer 1

2

I was able to find out the issue - rather than accessing the returned data via request.text, I used request.content which returned a bytes literal string. This opened up many more options for decoding and file writing.

1
  • Good job solving your problem and coming back here with the update Commented Aug 16, 2023 at 18:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .