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
Jorg_JankeJorg_Janke 

{!API.Session_ID} from URL not working from Lightning

We have a Url Button to access and process a record in Salesforce.
The user clicks a page link/button and the url which contains &sfSid={!API.Session_ID}&sfEndpoint={!API.Partner_Server_URL_360}
We use the endpoint/sid to log into Salesforce via SOAP and then access/process the record (cannot be done via APEX :-()

This works absolutely fine in Classic.
In Lightning, it works, if the Button is Detail Page Link with Display in new Window.
This creates an ugly full page screen with "You will be redirected to ... Click the button below to go to that page."

Looking for alternatives in Lightning, a Detail Page Button produces a nicer popup "Navigate to this page? .."
BUT when trying to login via SOAP with the endpoint/session provided via SOAP, we get the error:

[UnexpectedErrorFault [ApiFault  exceptionCode='INVALID_SESSION_ID'
 exceptionMessage='Invalid Session ID found in SessionHeader: Illegal Session'
]

The endpoint/sid "look ok".
Sometime ago, I read that there are different types of sid's ??

Obviously even in Lightning some values created by {!API.Session_ID} work and other's don't.
What are the different types or SID's and how do I manage/distinguish them?
How can I make it work in all cases??

Thanks!
Jorg
JLA.ovhJLA.ovh
By design, Lightning sessions are not expected to be used by API. There are some complex workaround (such as a merge field in a visualforce page from which you retrieve the content to get the session id) that are not maintainable and should not be used.Not testes but you could probably to relay to a Visualforce page that will target to the right url from the classic domain
Jorg_JankeJorg_Janke

Thanks - Odd thing is that it works in some URL and not in others.

How would I solve this issue in a "lightning compatible" and maintainable way?
i.e. call a url and passing sid/etc. so that the user does not have to log in again?