I'm trying to generate an external download link for a Document record I've created previosly on my org.

I've tried with

URL.getSalesforceBaseUrl().toExternalForm() + '/sfc/servlet.shepherd/document/download/' + documentID

But it's not working. I've also tried with the body URL but it gives me a file with the base64 Body of the document instead of the actual file

'/services/data/v51.0/sobjects/Document/' + documentID + '/Body'

Is there a way I can accomplish this?

1 Answer 1


You are asking about the old Document object, which does not appear to be supported in lightning.

This question is basically a duplicate of Access Document(pdf or doc) without Salesforce login. The answers there are still relevant to you, especially considering that you are still in classic.

You must log in to answer this question.

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