+ Start a Discussion
SFDC 2017SFDC 2017 

How to Integrate from one salesforce Org to another Salesforce Org using APEX REST API?i.e how to call through URL ?????????????

SarfarajSarfaraj
Salesforce to Salesforce is a Force.com feature that lets you configure two Force.com environments (orgs) so that they share data records in real time. It is natively supported. 
Check these for more details,

https://developer.salesforce.com/page/An_Introduction_to_Salesforce_to_Salesforce
https://help.salesforce.com/apex/HTViewHelpDoc?id=business_network_intro.htm
https://help.salesforce.com/HTViewHelpDoc?id=business_network_managing_leads.htm&language=en_US
https://help.salesforce.com/apex/HTViewHelpDoc?id=business_network_tips.htm
https://help.salesforce.com/apex/HTViewHelpDoc?id=business_network_enabling.htm
https://developer.salesforce.com/page/Best_Practices_for_Salesforce_to_Salesforce
 
SFDC 2017SFDC 2017
Thankyou @ akram.

My scenario i want to Integrate from one salesforce org to another salesforce Org using APEX REST API.Currently i referred Jitendrazaa Website for fetching data from one org to another using Remote site settings.But i want to call a method in Target ORG that i have written in my source ORG .How can we achieve this???

Any help will be Really Appreciable.Currently I am Using Basic Apex REST Example as follows:


@RestResource(urlMapping='/Account/*')
global with sharing class MyRestResource
{
@HttpDelete
global static void doDelete()
{
RestRequest req = RestContext.request;
RestResponse res = RestContext.response;
String accountId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
Account account = [SELECT Id FROM Account WHERE Id = :accountId]; delete account;
}
@HttpGet
global static Account doGet()
{
RestRequest req = RestContext.request;
RestResponse res = RestContext.response;
String accountId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
Account result = [SELECT Id, Name, Phone, Website FROM Account WHERE Id = :accountId];
return result;
}
@HttpPost
global static String doPost(String name, String phone, String website)
{
Account account = new Account();
account.Name = name;
account.phone = phone;
account.website = website;
insert account;
return account.Id;
}
}


How to call this in my Dev Org .I have added the URL OF the Source Org in Remote site settings in DEV Org.
But i am not clear how to call like https://ap2.salesforce.com/apexrest/Account or something like that .

Since I am new to Integration i am not able to do this.Everywhere they mention curl to check but i want to call the Url which i mapped first in the code.how to call this class method through URL in another org. 

can you guide me to get this done ...


Thanks in advance.
 
SFDC 2017SFDC 2017
I want this done using REST Api.


Thanks in advance....
 
AmrenderAmrender
Salesforce REST API call into Force.com platform requiresOAuth 2.0 authentication.
Below url may help you.
http://www.webtrafficexchange.com/salesforce-rest-api-example