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.
downloadExcelApiCtrl.apxc

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 lightning component.

  • 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 lightning component.

Related Topics | You May Also Like

Hi, This is Vijay 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.

Leave a Comment