Session ID with API 40 — Salesforce 365

Salesforce has stopped displaying “SessionId” on the Debug Log from Summer 17 (API 40) from security point of view. Until API 39, “System.debug(UserInfo.getSessionId())” was used to get SessionId. The Dev console is going to print “SESSION_ID_REMOVED” going forward.

We can still get the SessionId by using 2 UserInfo methods as below:

=================================================================== System.debug(UserInfo.getOrganizationId()+”+UserInfo.getSessionId().SubString(15)); ==================================================================

In the above line of code, SessionId is concatenated with OrganizationId (the first 15 digits of SessionId/access_token) which transforms into SessionId.

Session id with API 40

via Session ID with API 40 — Salesforce 365