AKH Coding Class
By Arun Kumar Hazra
Wednesday, August 26, 2026
Data Cloud Part 1: No Heavy Theory — Let’s Learn Salesforce Data Cloud by Building in a qucik, effective and smart way.
Thursday, August 6, 2026
Salesforce REST API: Upload a Files to a Record Attachments | Step-by-Step Guide
Uploading a file to a Salesforce record using the REST API is a straightforward process. In this tutorial, I'll walk you through the complete process using only four cURL commands.
The entire process consists of four simple steps:
Authenticate with your Salesforce org to obtain an Access Token.
Upload the file from your local machine to Salesforce using the Access Token. This request returns the ContentVersion Id.
Retrieve the ContentDocument Id using the ContentVersion Id.
Link the file to a Salesforce record using the ContentDocument Id.
That's it! With these four REST API calls, your file will be successfully attached to the desired Salesforce record.
What is cURL?
cURL (Client URL) is a command-line tool used to send HTTP requests to web servers and REST APIs. It is one of the most widely used tools for testing and interacting with REST services, including the Salesforce REST API.
Throughout this tutorial, we'll use only 4 cURL commands to perform all the API requests.
Do You Need to Install cURL?
Whether you need to install cURL depends on your operating system.
| Operating System | Is cURL Pre-installed? |
|---|---|
| Windows 10 (Version 1803+) & Windows 11 | ✅ Yes |
| Linux | ✅ Usually Pre-installed |
| macOS | ✅ Yes |
| Windows 7 / Windows 8 | ❌ Usually Not Installed |
How to Check Whether cURL is Installed
Open Command Prompt or PowerShell and execute the following command:
curl --version
If installed, you'll see output with it's version and if it is not there then you will get message like "'curl' is not recognized as an internal or external command".
Note: This tutorial assumes that cURL is already installed and available on your machine.
Let's Get Started
Now that we have a basic understanding of cURL, let's dive into the implementation.
In the following sections, we'll go through each of the four REST API calls required to upload a file and attach it to a Salesforce record, with complete request examples and explanations for each step.
Step 1: Authenticate with Your Salesforce Org and Obtain an Access Token
Open Command Prompt (Windows) and execute the following cURL command to authenticate with your Salesforce org.
Note:
The cURL command shown in the above article may be split across multiple lines for better readability. Before executing it in Command Prompt, remove the trailing backslash (\) from the end of each line and combine the entire command into a single line.
Note:
This highlighted Access Token, we will use in our next steps (Step-2)
Step 2:Upload the file from your local machine to Salesforce using the Access Token. This request returns the ContentVersion Id.
Note:
The cURL command shown in the above article may be split across multiple lines for better readability. Before executing it in Command Prompt, remove the trailing backslash (\) from the end of each line and combine the entire command into a single line.
Below is the Raw Command I used for my testing,
curl --request POST "https://lwcdmn-dev-ed.my.salesforce.com/services/data/v55.0/sobjects/ContentVersion" --header "Authorization: Bearer 00D7F0000LOVEAQN_u.PIqS6AKHfR2ZTtjk8QmBOEn56A7i1tcPshZOWHi5xReHVDR73m6dUMeyiIyDF43DWsW5CY" --form "entity_content={\"Title\":\"MediAssistCard\",\"PathOnClient\":\"MediAssistCard.pdf\"};type=application/json" --form "VersionData=@C:\Arun\MediAssistCard.pdf;type=application/octet-stream"
Note:
- This highlighted ContentVersion Id in GREEN, we will use in our next steps (Step-3).
- VVI: Please notice the highlighted parpel color in my raw command, this is very very important note. If you are using a quote under another quote then use this backslash (
\) before each quote which are part under a parent quotes. If you did a single mistake on syntax then it will be very hard to solve. So, be carefull on this command systax.- VVI: Try to use absolute path of your file location like I mentioned in ORANGE colour and keep your folder name without space.
Step 3: Retrieve the ContentDocument Id using the ContentVersion Id.
Note:
The cURL command shown in the above article may be split across multiple lines for better readability. Before executing it in Command Prompt, remove the trailing backslash (\) from the end of each line and combine the entire command into a single line.
Below is the Raw Command I used for my testing,
Note:
- This highlighted ContentDocumentId in GREEN, we will use in our next steps (Step-4).
Step 4: Link the file to a Salesforce record using the ContentDocument Id.
Open Command Prompt (Windows) and execute the following cURL command to attache the file to the Account Record (0017F000007A2eZQAS) by using the ContentDocumentId (069NS00000czFmRYAU) that we have received from Step-3 response.
Below is the Raw Command I used for my testing,
curl -X POST https://lwcdmn-dev-ed.my.salesforce.com/services/data/v55.0/sobjects/ContentDocumentLink -H "Authorization: Bearer 00D7F000000saHD!AQEAQN_u.PIqS6kPhfinZG49wp3AYsp7IBfR2ZTtjk8QmBOEn56A7i1tcPshZOWHi5xReHVDR73m6dUMeyiIyDF43DWsW5CY" -H "Content-Type: application/json" -d "{\"ContentDocumentId\" : \"069NS00000czFmRYAU\",\"LinkedEntityId\" : \"0017F000007A2eZQAS\",\"ShareType\" : \"V\",\"Visibility\" : \"AllUsers\"}"
Response I received:
{"id":"06ANS00000XYZUb2AL","success":true,"errors":[]}
After successfull completion of above step-4, if we check our Salesfroce record then we will file the respective file will be attached under the mentioned record (for our case Account Record),
Final Note:
Sunday, June 18, 2023
LWC to LWC Communication using Lightning Messaging Service (Part - 2)
In my previous post (previous post link) we have learn how to create a Lightning Messaging Service with 6 steps and today we will use the same Lightning Messaging Service to communicate between 2 LWC components.
Solution:
Step-1:
Step-2:
Step-3:
Step-4:
Step-5:
And after save and activate this page, search for "Lightning Messaging Service Example" whcih is my App Page as created above screen and then click on it and it will be look like below screen,
Step-6:
Test-2: Click on "Publish" button after enter some input text under "LWC One Component" and after click on "Publish" button, inputted value will be pass from Component One to Component Two and it will display below message in "LWC Two Component".
LWC to LWC Communication using Lightning Messaging Service (Part - 1)
Scenario: Our aim is to send some message from 2 different LWC Components where there is no Parent Child relationship between them and we will pass this message using Lightning Messaging Service.
After completing this assignment we will execute the below Screen, where in 1st LWC component (LWC One Component) has an Input field and a Submit button named as "Publish".
If user input some value and click on "Publish" button then 2nd LWC component (LWC Two Component) will display the message passed in component one's input filed.
Solution:
First we will follow below 6 Steps to implement Lightning Messaging Service and then we will apply this LMS with 2 LWC Components:
Step-1:
Step-2:
Step-3:
Step-5:
Step-6:
Friday, February 17, 2023
Salesforce and Open AI's GPT-3 (Chat GPT) Integration Sample Apex Code.
I have implemented a simple use case to communicated between Salesforce and Open AI's GPT-3 (Chat GPT).
Click on the below link to get the full video details,
Use Case Details:Click on the blow link to check what is ChatGPT and how to create an account:
Sunday, January 1, 2023
Create a Program to Find Armstrong Number | Java While Loop | Class#34
Check the YouTube Description for more high level theory details and assignment if design for this video.
If you love this then please don't forget to Like, Share and Subscribe my YouTube Channel.
Friday, December 2, 2022
Print a Number in Reserve Order | Java While Loop | Flow Chart | Class#33
Click on the below link to check the video 👇
Check the YouTube Description for more high level theory details and assignment if design for this video.
If you love this then please don't forget to Like, Share and Subscribe my YouTube Channel.
Data Cloud Part 1: No Heavy Theory — Let’s Learn Salesforce Data Cloud by Building in a qucik, effective and smart way.
In one line: Data Cloud connects your data, understands your customer, and helps Salesforce take smarter action. Scenario 1 : I Already Bo...


