Understanding The Flow of Salesforce Integration With Any Third Party API

When it comes to Integration with any other Technology we all have doubts like :

"How to Start ?" ,

"How to make your First API Call & see the Response ?"

The Answer is POSTMAN. With the help of this Tool you can easily make REST API Calls using its wonderful UI & can see Responses very well. Moreover it also helps you in understanding the Flow of Integeration.

postman-rest-client1

INSTALLATION : https://chrome.google.com/webstore/detail/postman/fhbjgbiflinjbdggehcddcbncdddomop?hl=en

Once Installed.It will Look something like this -

Screenshot from 2017-04-21 21:24:21
Now Let me give you a Demonstration that will explain you a flow of REST API Integration of Salesforce with this POSTMAN(acting as a third party software).Your third Party Tool can be any , the Process will remain the same.

1.) Open POSTMAN -> Select Oauth 2.0 ( Authorization Framework ) from the Drop Down Picklist ->

1

->Click on Get New Access Token Button -> Copy the Callback URL

Screenshot from 2017-04-21 21:41:04

I will explain you later why i have copied this.For now just copy it.

2.) Now you need to Create a Connected App in Salesforce as the third Party(POSTMAN) is getting Integrated with it.For that

Go to your Salesforce Org -> Build -> Create -> Apps -> At the bottom you will see New Button.Click on it and fill details like this:

Screenshot from 2017-04-21 21:38:49

Now you can see where you need to fill the Callback URL.I will explain you later in the post what is the need of this Callback URL.

In Connected App Click Manage Button and Set - IP Relaxation To Relax IP restrictions

c

3.) After the Connected App gets created , Copy the Consumer KeyConsumer Secret and paste it in a Notepad.

4.) Now go to this link https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/intro_understanding_oauth_endpoints.htm and Copy and paste these 2 https -

For authorization: https://login.salesforce.com/services/oauth2/authorize

For token requests: https://login.salesforce.com/services/oauth2/token

***NOTE - Replace login with your Salesforce Instance.

Now we all this in Notepad:

aCCESS tOKEN

5.) Now Fill these :

g

and Click on Request Token.

6.) A Popup will open which will ask for login into your Salesforce Org in which Connected App is created.As soon as you enter your credentials you will be redirected to your POSTMAN (this is what Callback URL does - the URL where you will be redirected as soon as you will login into your Salesforce Org for Authorization).

b

7.) Now you will recieve you request token.

6. Make an API call with that Access Token

Then Click on Use Token Button.As soon as you click on this button, your Header will look something like this :

7. The access token is an OAuth bearer token and is included in the header of your requests

The digits written to the right of Bearer is the Access Token i.e ( Authorization = Bearer + Access Token ).

8.) Now in the Address Bar of POSTMAN Enter - https://ap2.salesforce.com/services/data/v39.0/sobjects/account

This is basically your Endpoint url. Replace ap2 with your salesforce Instance.

9

9.) Now Click on Send Button.As soon as you click send button you will get Response with all the Accounts (As you have requested /account in the url - https://ap2.salesforce.com/services/data/v39.0/sobjects/account).

10

Congratulations this third Party POSTMAN has been integrated with your salesforce.As on hitting the /account requests in this third Party POSTMAN , your'e getting your accounts.emoji1

So the Short Recipe for this is :

  • First you will make a token call (https://login.salesforce.com/services/oauth2/token) with the Consumer Key & Consumer secret.
  • Then you will recieve Request Token which you will add it in the header i.e [ Authorization = Bearer + Access Token ].
  • Then you will make a REST API Call with Get method to the Endpoint url -https://ap2.salesforce.com/services/data/v39.0/sobjects/accountReplace ap2 with your salesforce Instance.Then you will get whatever you have requested.The Endpoint url -  https://ap2.salesforce.com/services/ remains same till /services, after that it changes depending upon the Requirement.
  • ***NOTE - Here your'e making GET Request (For getting any data from your Salesforce Org to your Third Party App- here POSTMAN).For POST Requests you will need to add Content-Type also in the Header like this -
  • 7

Whatever you are Integrating with Salesforce in future, this Flow will remain Same.Always refer to the API Guides of the Application which you want to Integrate it with Salesforce.Read From start till End carefully , each & every Line.

KEEP CALM AND LOVE API's 31163A0400000578-3442108-image-a-27_1455189872679

Popular Salesforce Blogs