uploading files to SFDC attachment object using REST call -- w3web.net

Inserting file in Salesforce file/attachment object Using custom REST API Uses property of “ContentVersion”, “ContentDocumentLink” and “getBodyAsBlob()” in apex class post method in Salesforce | File upload to Salesforce object using custom REST API


Hey guys, today in this post we are going to learn about How to call an external REST API to uploading files to SFDC file/attachment object using REST call in Salesforce Apex Post Methods.

This example we are uploading files to Salesforce object using custom REST API and property of ContentVersion, ContentDocumentLink and getBodyAsBlob() in Salesforce Apex Class Post Method.

To access the external REST API, First we need to Adding the Remote Site Settings

SetupRemote Site SettingsRemote Site Name Enter the URL for the remote site

Files we used to upload file in Salesforce

apiIntegrationCmp.cmp Lightning Component It is used to uplod the file into salesforce object from custom REST API using apex post method in salesforce.
apiIntegrationCmpController.js JavaScript Controller File It is hold Javascript apiIntegrateAction function to call the apex class method and insert file to salesforce object.

Apex Class Controller It is used to get the file from custom API and uploading files to SFDC using Apex post method.
Salesforce Object

Object Name:- Opportunity
Related Object’s Name:- File/Attachment


Other related post that would you like to learn in Salesforce


  • Find the below steps:-

Create Lightning Component

Step 1:- Create Lightning Component : apiIntegrationCmp.cmp

From Developer Console ➡ File ➡ New ➡ Lightning Component

apiIntegrationCmp.cmp [Lightning Component File]

Create Component JavaScript Controller

Step 2:- Create Lightning Component : apiIntegrationCmpController.js

From Developer Console ➡ File ➡ New ➡ Lightning Component ➡ JavaScript Controller

apiIntegrationCmpController.js [JavaScript Controller]

Create Apex Class Controller

Step 3:- Create Apex Class : downloadExcelApiCtrl.apxc

From Developer Console ➡ File ➡ New ➡ Apex Class

downloadExcelApiCtrl.apxc [Apex Class Controller]

uploading files to SFDC attachment object using REST call -- w3web.net


Further post that would you like to learn in Salesforce



FAQ (Frequently Asked Questions)

What is a custom REST API?

Custom REST APIs to build up a library of services that can be used by your mobile apps and intelligent bots.

What is REST API services?

A REST API is an application programming interface that conforms to the constraints of REST architectural style and allows for interaction with RESTful web services.

What is REST API vs API?

REST basically is a style of web architecture that governs the behavior of clients and servers. While API is a more general set of protocols and is deployed over the software to help it interact with some other software.

Related Topics | You May Also Like

  • Your reaction of the article ▾

Hi, This is Vijay Kumar behind the admin and founder of w3web.net. I am a senior software developer and working in MNC company from more than 8 years. I am great fan of technology, configuration, customization & development. Apart of this, I love to write about Blogging in spare time, Working on Mobile & Web application development, Salesforce lightning, Salesforce LWC and Salesforce Integration development in full time. [Read full bio] | | The Sitemap where you can find all published post on w3web.net

Leave a Comment