How to integrate Salesforce with a third party Application

How to integrate Salesforce with a third party Application

Developers often face the challenge of integrating Salesforce with a third party Application. This is same as consuming external API in Salesforce.

Some use cases:

  • Uploading files to AWS, Google Drive, Dropbox from within Salesforce
  • Sending data to external Apps such as email or SMS from Salesforce
  • Updating your financial system from Salesforce and more…

There are many Apps available on AppExchange for most commonly used external systems. However, if your application is not among these, you can follow these general guidelines to integrate the application.

Steps to integrate with an Application

First your application should have well defined API. API is nothing but a set of rules on how the external party communicates with your application. There will be end point, methods, expected parameters and response.

Second, read and explore a bit of HTTP request class: Also, the HTTP response class:

As the name suggests, using request class we can send a request to a third part application. And using response class, we can read the response sent back by the third party Application.


Next, we will create apex code to send a request and receive response from an application.

For example, if we consider Google Places API:

Let’s say I wish to get auto suggestions from Google when my users start typing the name of a place. If you read a bit on the available API’s, you will know that Places Autocomplete API matches our requirement.

Important before writing the Apex Class

Add the base end point ( in this case) to Remote Site Settings in Salesforce setup.

If you have read through the HTTP request class, first we need to create a request.

String strURL=''; // Here set the endpoint.
Http h = new Http();
HttpRequest req = new HttpRequest();

The end point in the documentation is Therefore, for this example strURL can be:'
                 + 'input=' + EncodingUtil.urlEncode(input, 'UTF-8')
                 + &key=' +key;

Here, input is the string entered by the user and key is the Google API key.

Now to receive the response, we will use the HTTP response class:

HttpResponse res = new HttpResponse();
res = h.send(req); //sending the request to the external application
String responseBody = res.getBody();

Notice that we used Json for output format in the endpoint. Thus, The response can be parsed using Json Class.

Another example: MailChimp API. Let say we want to add a contact to our Mailchimp List.

As per API documentation, the end point is https://<dc> where dc is the datacenter. Your data center would be in the URL once you login in Mailchimp.

How to integrate Salesforce with a third party Application

In the above screenshot, my data center is ‘us3’.

Also, as per the API document we need to send ‘POST’ request to ‘ /3.0/lists/<list id>/members/ ‘ . List Id to located at Audience->Settings->Unique Id for Audience.

Thus our request code becomes:

Http h= new Http();
HttpRequest req = new HttpRequest();
req.setHeader('authorization','apikey '+apikey);//replace with API key
req.setBody('{"email_address": "","status": "subscribed","merge_fields": {"FNAME": "Urist", "LNAME": "McVankab"}}');

The API key is located at Account->Extras->API Keys

In real life, you would probably take input from user and send that as Body to the API.


While each API is different, basic structure is same. Some like AWS S3 have complex authorization mechanism. Salesforce API itself returns session and instance token on authorization through API, which can be used in next step for any activity.

In conclusion, it is not difficult to integrate Salesforce with a third party Application. We only need to understand the API documentation well.

It is also a good idea to test the API using Postman or other such applications. This will give you clarity on how the API works.

Leave a Reply

Your email address will not be published.

Scroll to top