You need to sign in to do that
Don't have an account?
Alex.Acosta
API Session Id for external integration
API Session Id
I've been trying to find a work around for this issue. Basically, if I use the merge field {!$Api.Session_ID} on a button, the session Id is value and works just fine. If I attempt to use the same Api.Session_ID within either a formula field on a sObject, or within the APEX VisualForce page as a standalone merge field the session is no longer valid and fails when an outside source attempts to use that session Id. Would anyone know why and/or a work around for this?
The problem here is that a Salesforce Session Id is associated with a particular end-point server. In the case of the button on the Visualforce page, the session id you'd get from an Apex UserInfo.getSessionId() call would be associated with the Visualforce server you're interacting with. That's a problem because the Report servlets from which we retrieve report data aren't available from the Visualforce servers -- only from the "front-end" servers (na1, na2, emea, etc.) .
All Answers
Are you passing Session Id from URLusing that field? are you performing url decode and encode on anyside?
There are 2 ways I attempted this
1) Within the VF page I was trying to generate my URL:
2) Within Apex Code:
Since I was unable to find a way to get the API session Id within my the Apex Class side, I just make a formula field which had the value you see above to dynamicly generate my session Id. The reason for this is because if i'm not mistaken the user session id is different from the api session id. So within Apex my logic looked something as such
Both of these failed. But if i used the same logic on a button on the sObject that you can put on a page layout ie:
and copied my session Id from what this button generated the used it for both examples above, it would work.
Hi,
When i tried the following code snippet at my end on VF page by giving the session id it worked.Please follow this sample code it wil help resolve your problem:-.
<script src="/soap/ajax/23.0/connection.js" type="text/javascript"></script>
<script type="text/javascript" src="/js/functions.js"></script>
sforce.connection.sessionId="{!$Api.Session_ID}";
alert(' Session Id ' + '{!$Api.Session_ID}');
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
Thanks for the reply and I attempted to implement this, but sadly it did not work. I'm trying to provide the session id as a parameter in the url to conga composer.
The problem here is that a Salesforce Session Id is associated with a particular end-point server. In the case of the button on the Visualforce page, the session id you'd get from an Apex UserInfo.getSessionId() call would be associated with the Visualforce server you're interacting with. That's a problem because the Report servlets from which we retrieve report data aren't available from the Visualforce servers -- only from the "front-end" servers (na1, na2, emea, etc.) .
Hi Alex,
I am facing the same problem
Were you able to figure out how to pass the session id and URL?
If this is for conga, you'll need to install their conga query app and use that rather than reports.
Direct Link to install: https://login.salesforce.com/?startURL=/packaging/installPackage.apexp?p0=04t70000000cbJu
Or go to their site http://home.appextremes.com/support/ > click Installations sub tab, and scroll all the way to the bottom to find the link
HI, I want to know what to write in onclick javascript custom button; so that after clicking I would get whether the session is expired or not ??????
PLease post ASAP
try this
{!requireScript("/soap/ajax/26.0/connection.js")}
alert(sforce.connection.sessionId);