Posts

Showing posts from December, 2018

Calling REST API in one Org from another Org

Image
1. Write an API as per requirement & expose it. 2. Create 'CONNECTED APP' in Target Org. (Org where you have exposed API) 3. In Source Org (Org from where you are call API in Target Org), create 'REMOTE CONNECTION' of Target Org. 4. Create Apex class in Source Org to call API in Target Org. ---------------------------------------------------------------------------------------------------------------- public class AccountRestExampleConsumeFromOtherSFOrg{          public String AccountRestExampleConsumeFromOtherSFOrg(){                  String endpoint='https://login.salesforce.com/services/oauth2/token';                  String username = '***********';          String password = 'password+securitytoken';         String ClientId= '************';         String ClientSecret = '**************';                   Httprequest req = new HttpRequest();             req.setMethod('POST');             req