0

After creating a public link of a File using ContentDistribution, you get the below URL

https://--c.documentforce.com/sfc/dist/version/renditionDownload?rendition=ORIGINAL_Jpg&versionId=068q0000000RAdv&operationContext=DELIVERY&contentId=05Tq0000001RiQf&page=0&d=/a/q00000008a0b/6woo3x9YQNR7vTXR2oOOmknAOjpytHMEnZc2nGQ3F54&oid=&dpt=null&viewId=

How to query the Content Id of a File? I can see the URL already contains the Version Id this means the Content Id is something diffrent.

2
  • By the way, just in case, this feels like it might be a X-Y Problem. You may want to ask your "X" question directly.
    – sfdcfox
    Jul 28, 2021 at 5:01
  • Sure will correct it Jul 28, 2021 at 5:29

2 Answers 2

3

The Content Id in the URL is a ContentBody, which states:

Cannot be queried, inserted, updated, or deleted directly.

...

ContentBody is intended for internal Salesforce use. If you need to access the file content body, please use ContentVersion.

In other words, you're not meant to use this Id. If you need to generate a public link, create a ContentDistribution record. Note that even if you could query ContentBody, it wouldn't be valid without a valid ContentDistribution.

1
  • Thanks for the response, it lead me in to the correct direction. Jul 28, 2021 at 5:31
0

If someone else lands here the Content Id in the URL is ContentBodyId which is present inside the ContentVersion.

ContentBodyId Description: Allows inserting a file version independently of the file blob being uploaded. This field is available for query and insert only. It can only point to a ContentBody record. This field is available in API version 40.0 and later. This is a relationship field.

Ref: https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_contentversion.htm?search_text=Content%20Body

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.