1. Create a Connected App in Salesforce.
Callback URL should be https://{Your Salesforce Domain}.my.salesforce.com/services/oauth2/callback.
My Org Callback URL is https://test-ec-dev-ed.develop.my.salesforce.com/services/oauth2/callback.
2. Do a POST Request to https://{Your Salesforce Domain}.my.salesforce.com/services/oauth2/token to get the access token.
My Org Token Endpoint URL is
https://test-ec-dev-ed.develop.my.salesforce.com/services/oauth2/token
3. Do a POST Request to https://{Your Salesforce Domain}.my.salesforce.com/services/data/v55.0/sobjects/ContentVersion/ to create ContentVersion record.
My Org ContentVersion endpoint URL is
https://test-ec-dev-ed.develop.my.salesforce.com/services/data/v55.0/sobjects/ContentVersion/
Sample POST body:
{
"Title" : "Test",
"PathOnClient" : "test.txt",
"ContentLocation": "S",
"VersionData": "VGVzdGluZw=="
}
Here “VGVzdGluZw==” set in VersionData is nothing but Base64 Encoded value for “Testing”.
4. Do a GET request to https://{Your Salesforce Domain}.my.salesforce.com/services/data/v53.0/query/ to get the ContentDocumentId.
My Org Query endpoint URL is
https://test-ec-dev-ed.develop.my.salesforce.com/services/data/v53.0/query/
Query Params:
q = SELECT+ContentDocumentId+FROM+ContentVersion+WHERE+Id=’0683t00000LqUIbAAN’
5. Do a POST Request to https://{Your Salesforce Domain}.my.salesforce.com/services/data/v55.0/sobjects/ContentDocumentLink/.
My Org ContentDocumentLink Endpoint URL is
https://test-ec-dev-ed.develop.my.salesforce.com/services/data/v55.0/sobjects/ContentDocumentLink/
Sample Body:
{
"ContentDocumentId" : "0693t00000L22SHAAZ",
"LinkedEntityId" : "0013t00002XXRyDAAX",
"Visibility": "AllUsers"
}
Output: