[SalesForce] Session expired or invalid

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

Best Answer

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

enter image description here