0% found this document useful (0 votes)
80 views5 pages

How To Integrate One SFDC Org To Another SFDC Using Rest API - Salesforce® Discussions - Forcetalks

Uploaded by

hhhh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
80 views5 pages

How To Integrate One SFDC Org To Another SFDC Using Rest API - Salesforce® Discussions - Forcetalks

Uploaded by

hhhh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Reply

How to integrate one SFDC org to another SFDC using Rest


API? Subscribe

 shariq updated 3 years, 5 months ago


4 Members
·
4
Posts
Salesforce® Discussions

Callout, Callout Integration, Destination Org, Rest API, Rest API Call, Rest Resource,

Salesforce Apex Class, Salesforce Integration, Salesforce Org, Salesforce REST API, SFDC, SFDC Org

chanchal kumar
Member July 10, 2018 at 1:15 pm

How to integrate one SFDC org to another SFDC using Rest API?

Avnish Yadav
Member July 10, 2018 at 2:03 pm

Hello Chanchal,

You want to integrate(means Callout) from one Salesforce org(Source org) to another Salesforce
org(Destination org).

Here is simple steps to complete the task:-

1. Create a new Remote Setting in Source org.


2. Create a Connected App in Destination org with unique callback URL.
3.  Create a apex class in Source org which take inputs of Connected app (i.e. Consumer Key,
Consumer Secret, Callback URL, Username and Password) of Destination org. This give you
access token for Destination call.
4. Create an Rest Resource apex class in Destination org which return some data(for doGet Call) or
accept some data(for doPost Call).
5. Create an another class or function in Source Org to retrieve the call with endpoint URL.
6. That's all.

Note - Use Debug to find error.

Thanks.

We use cookies to enhance your browsing experience. Please see our privacy policy if you'd like more information

on our use of cookies.


Ok
Parul
Parul
Member September 15, 2018 at 7:17 am

First we talk what we have to do in the in the Destination org:


Reply

Step 1.  Create a Connected app in Destination org giving the callback url with the details as mentioned
Subscribe
in the image below.

Step 2. Create a Rest Webservice with @httpPost & @httpGet verb, though it’s not required in
our case.

Now is the time to configure the Source org:

Step 1. Create Remote site in Source like in my case I created the below one.

Step 2. Create a class for Rest Callout in the Source org.

Thanks

shariq
Member September 15, 2018 at 6:28 pm

Hi,

One of the ways to Integrate two Salesforce Instances will be using oauth for session management and
using REST API

Lets Assume you have SalesforceA as Source ORG and SalesforceB as Destination ORG .Now lets
assume flow of data is from SalesforceA to SalesforceB Instance

1)For oauth 2.0 in Destination org(SalesforceB) create a Connected App .To help you configure the
Connected App in Destination below screenshot should assist.Callback Url may not be of any
significant as we are using User-Name Password flow model.You will obtain client secret,consumer key
in this process and one should store in Source org custom object or custom setting

2)In your source org create a Remote site settings with url as the URL of the Destination Instance

3)Create a Integration User in the Destination org whose credentials you will use to call API from
Salesforce Source ORG

4)Use the username,password and security token(Also i would prefer setting password never expires
here for integration User) and also client secret and consumer key in a custom object or custom
setting (Protected) in Source org.
We use cookies to enhance your browsing experience. Please see our privacy policy if you'd like more information
The below code is sample code to get authenticated and how to use access token to further make any
API call- on our use of cookies.
Ok
Settings__c ts=settings;//Here write a sample query or fetch from custom settings the consumer ,client
secret and username and password of destination org

String clientId = ts.ConsumerKey__c;

String clientSecret = ts.Client_Secret__c;

Reply
String username=ts.Username__c;

String password=ts.Password__c+ts.SecurityToken__c;
Subscribe
String reqbody =
'grant_type=password&client_id='+clientId+'&client_secret='+clientSecret+'&username='+username+'
&password='+password;

Http h = new Http();

HttpRequest req = new HttpRequest();

req.setBody(reqbody);
req.setMethod('POST');

req.setEndpoint(ts.URL__c+'/services/oauth2/token');//Note if my domain is set up use the proper


domain name else use login.salesforce.com for prod or developer or test.salesforce.com for sandbox
instance

HttpResponse res = h.send(req);

OAuth2 objAuthenticationInfo = (OAuth2)JSON.deserialize(res.getbody(), OAuth2.class);

RequestWrapper reqst=new RequestWrapper();

if(objAuthenticationInfo.access_token!=null){

Http h1 = new Http();

HttpRequest req1 = new HttpRequest();

req1.setHeader('Authorization','Bearer '+objAuthenticationInfo.access_token);

req1.setHeader('Content-Type','application/json');

req1.setHeader('accept','application/json');

req1.setBody(jsonstr);//Send JSON body

req1.setMethod('POST');

req1.setEndpoint(ts.URL__c+URL);//URL will be your Salesforce REST API end point where you will do
POST,PUT,DELETE orGET

HttpResponse res1 = h1.send(req1);

system.debug('RESPONSE_BODY'+res1 .getbody());

To deserialize the initial response here is wrapper class the above code uses-

/*To get aouthentication detail Wrapper*/

public class OAuth2{

public String id{get;set;}

public String issued_at{get;set;}

public String instance_url{get;set;}

public String signature{get;set;}

public String access_token{get;set;}

We use cookies to enhance your browsing experience. Please see our privacy policy if you'd like more information
}

Hope this helps.


on our use of cookies.
Ok
Viewing 1 - 4 of 4 posts

Log In to reply.

Reply

Subscribe

Popular Salesforce Blogs

Why Having a Salesforce Admin Online Training an


Salesforce
ExcellentFinancial
Idea? Services Cloud | Em
Innovation
BLOG
in Salesforce Admin
BLOG
in Salesforce Products
In today's job market, professional courses Salesforce administration & development course
is the assets you can have. It'll add value to your resume and also…
Loans and Mortgages are key elements of t
every adult at some time or other has been
Salesforce Adminstrator, Salesforce Certification, Salesforce CRM, Salesforce Developer, Salesforce
Development 360-Degree Customer View, Customer Feedbac
Salesforce Features

Srinath BigClasses
Popular Salesforce
Sep 13, 2019 Videos
DemandBlue
We use cookies to enhance your browsing experience. Please see our privacy policy if you'd
Dec 19, 2019 like more information

on our use of cookies.


Ok
Reply

Subscribe

What is Salesforce Hyperforce? Top 3 Interview Tips | How To Land A S

VIDEO
in Salesforce Products VIDEO
in Others, Salesforce Training

In this video, you will take a look at Salesforce Hyperforce,


In this
Salesforce's
video, bradnew
discusses
re-architecting
the TOP 3 way
of the Salesforce platform. 00:00 Introduction 00:28 WhatSalesforce
is Salesforce
Professional.
Hyperforce?…
These tips apply to

Salesforce Training, dreamforce, salesforce, salesforce platform,


Salesforce
Salesforce
Training,
Org Salesforce Jobs, salesforce

Pooja Bradley
 640 Views
Jun 9, 2021 Jun 8, 2020

QUICK LINKS COMPANY SUBMISSIONS

Advertise with Us Contact Us Write a Blog


[email protected]
Salesforce® Articles About Us Start a New
Discussion
Dreamforce 2021 Privacy Policy

Post a Video
Top Salesforce® Terms & Conditions
Bloggers 2021 Post an Infographic Get
Listed
Tips to choose Best
Salesforce®
Consulting Company

© 2022 - Forcetalks

All Rights Reserved
Salesforce® is a trademark of Salesforce® Inc. No claim is made to the exclusive right to use “Salesforce”. Any services offered

within the Forcetalks website/app are not sponsored or endorsed by Salesforce®.

We use cookies to enhance your browsing experience. Please see our privacy policy if you'd like more information

on our use of cookies.


Ok

You might also like