1

I am trying to Upload the File against Lead via REST API.

My understanding is that I need to use ContentDocument and then create Content Document Link against that Lead.

However, I am unable to upload file using Content Document end point and in docos there is no create endpoint (https://developer.salesforce.com/docs/api-explorer/sobject/ContentDocument/get-contentdocument-id)

In simple terms - what would be best way to upload a File against Lead, so it shows itself under Files widget in Salesforce.

Disclaimer: I trailed internet for solution but none seem applicable in my scenario

3

You cannot directly create a ContentDocument. Instead, you must upload a ContentVersion. The parent ContentDocument will be created for you automatically.

To link the file to an sObject, either set the FirstPublishLocationId field on the ContentVersion to the target record's Id, or query for the ContentDocumentId after insertion (it will be populated by the system) and add one or more ContentDocumentLink records to connect to sObject records.

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.