• Tomáš Migra 8
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
Hello Experts,

I want someone to put some light to teh new feature introduced by salesforce Named credential

My scenario is somethign like this:
1.I have a rest based webservice in target org which i am invoking through source org
2.I have created named credential in source org as shown below
User-added image
3. Further in my code that invokes the webservice i have written the below satatements:
HttpRequest req= new HttpRequest();

String reqBody='{"vEmail":"'+email+'",'+'"vSubject":"'+subject+'",'+'"vDate":"'+dt+'"}';
		req.setEndpoint('callout:ExternalPortalCreds');
		req.setMethod('POST');
		req.setBody(reqBody);
		Http http=new Http();
		HttpResponse res= http.send(req);

However this gives error as Session expired or invalid session id. How do i get the session id if i want to use named credential in my code?
Any help would be appreciated

Regards
Neha