[SalesForce] better rest endpoint for downloading file contents

I'm trying to use https://[domain]/sfc/servlet.shepherd/version/download/ to download files (lightning files not attachments) from salesforce and it works sometimes and I can get it to work in postman be in some cases it returns a 200 status but the contents are the following:

"https://[domain]/ex/errorduringprocessing.jsp"

The weird thing is that I can produce this error in postman if I leave it for a while and try to execute the request without getting a new token so it seems to be related to the tokens somehow. Does anyone know why this might happen?

Best Answer

To get a blob (binary data), you can use the SObject Blob Retrieve rest API call. This would be the preferred mechanism for doing so. The other URI is meant for UI downloads, not API calls.

Related Topic