After learning the REST API, it's always good to do some practice to make the concept more clear. In this Blog, we will Integrate Two Salesforce Org Using REST API. After Successful Integration, when we create an Account (whatever you want) in first (Source) Org, it will automatically get created in second (Target) Org.
Don’t forget to check out: Salesforce REST API
Now here are the Steps for Salesforce to Salesforce Integration Using REST API:
- First Create Remote Site Setting in First (Source) Org and Enter Required Fields
- Enter the Target Org Url (Check your Destination Org Instance). For e.g my I used "https://ap4.salesforce.com" Change ap4 according to yours
- Now Create Connected App in your Second (Target) Org
- Enter the Required Details and Enable the Oauth Setting and Enter the Callback URL (shown in the figure) but change the Instance to First Org Instance and Specify the Access (How much access you want to give to other Integrated Org).
- After Creating Connected App Copy the ClientId And ClientSecret To be used in Code.
- Now Go to Connected app "MANAGE " option and change the IP Relaxation to "Relax IP restrictions".IP Restriction can prevent you to get Access Token.
- Now Create an Apex Class in Source Org and Mention the Credentials like username and password of Target Org and then run a future Method to create an Account Asynchronously in Target Org.
- Make a trigger on insert and call the above class.