9

I am trying to build Salesforce to Salesforce integration using Named Credentials.

Followed steps from below blog.

http://www.jitendrazaa.com/blog/salesforce/salesforce-to-salesforce-integration-using-named-credentials-in-just-5-lines-of-code/

  • Created Connected App in destination org
  • Created Authorization Provider in source org
  • Defined Named Credential in source org.

    HttpRequest feedRequest = new HttpRequest();
    
    feedRequest.setEndpoint('callout:Dev3Org/services/data/v32.0');
    
    feedRequest.setMethod('GET');
    
    Http http = new Http();
    
    HTTPResponse feedResponse = http.send(feedRequest);
    

When I ran above code in Source Org (anonymous window) then am getting below error

Session expired or invalid

2

3 Answers 3

4

when I checked Generate Authorization Header check box on Named Credential then error went off.

enter image description here

1
  • hey, where is the above option in salesforce dashboard? Commented Jan 3, 2018 at 14:05
0

Named credentials works fine. It looks like request is reaching the host and you are getting the response as session expired. In Named Credentials you can set basic authentication or oauth please check which one of them are being used.

1
  • I have specified OAuth 2.0 in Named Credentials
    – sfdc
    Commented Dec 15, 2015 at 16:36
0

Yes... Finally... I am able to get the response from other org...

Make sure that while creating named credentials.. you should give URI as "https://xxxxxxxxxx-dev-ed.my.salesforce.com"

I gave "xxxxxxxx-dev-ed.lightning.force.com" >>> Throwed the error...

so correct URI is "https://xxxxxxxxxx-dev-ed.my.salesforce.com".

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .