I am building sfdc application that required me to call and do add/update using Http method at vendor application in external server daily. They created one account for me in their application. In order to proceed with data manipulation at their application, I need to retrieve the token by passing my session id using UserInfo.getSessionId().
After retrieved the token, then I am able to do other process.The issue is, when I run my code in Apex Execute I am able to retrieve UserInfo.getSessionId(), but when I put in Schedule and run it ,the session Id return null.
global class Test_Sched implements Schedulable{
global void execute(SchedulableContext sc) {
System.debug('Test ' + UserInfo.getSessionId()); //This returning null
String sessionId=UserInfo.getSessionId();
//pass the session id to the class that call http and process the data in external apps
staticclassprocess(sessionId) ;
}
}
I read the documentation here When do Sessions expire? but still not able to understand how to pass the sessionId from scheduler.