function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
onlinenandaonlinenanda 

How to get server url and session id in apex class - i don't want to use apex page to get that one

How to get server url and session id in apex class - i can not use visual force page to get that one.

 

your help is appreciated..

WhyserWhyser

Not sure about server URL but you can get the session ID by

 

String sessionID = UserInfo.getSessionId();

gv007gv007
System.currentPageReference() check this class
ddkpeddkpe

I am having the same problem.

 

Is using UserInfo.getSessionId() really equivalent to $!Api.Session_ID in the same Visualforce page context?

 

When I look at the output results of {$!Api.Session_ID} and {$!SessionId} merge variables in the same URL string (where {$!SessionId} is the result of an Apex controller get method of UserInfo.getSessionId) the values start out similarly for the first 25 characters or so, then diverge completely.

 

Why are the different?

 

Should I care that they are different?

 

Is using the Apex UserInfo.getSessionId() value "valid & correct enough" for my application to use to access the Salesforce Web Services API?

 

 

tchrisbakertchrisbaker

@ddkpe,

 

I am having the same issue with them being different. Did you ever figure this one out?