Code -

String sessionID = UserInfo.getSessionId();

Should give me Session ID, Urgent as I require it for use in SOAP UI. Is there any workaround

  • 1
    according to this salesforce.stackexchange.com/questions/179845/… you can no longer see session id in debug logs though we can put it in use just cant print it
    – User6670
    Feb 20 '20 at 8:12
  • @User6670 thanks a lot. Found this workaround system.debug(Userinfo.getSessionId().subString(1,Userinfo.getSessionId().length())); and it works as expected. Feb 20 '20 at 8:22

Yes, it has workaround to see sessionId in Debug Logs:

system.debug(UserInfo.getOrganizationId() + UserInfo.getSessionId().substring(15));

Since first 15 characters of session id is organization id, and debug logs perfectly show parts of session id string.

  • After a bit research, I came to know that session id starts with 005, to identify the session id, salesforce just checks these first three digits and marks it as session id, so even if we trim the first three digits in debug of session id, it should work, and then we can add 005 later whenever you want to use it @MariiaIllarionova Feb 20 '20 at 12:14
  • Please can you look into this Feb 20 '20 at 12:19
  • Yes, sure, it;s the same that I mentioned, session Id starts with organization Id, AND organization Id always starts from 005, so you are right, you can set it like you mentioned in comment too. Feb 20 '20 at 12:21
  • that was helpful, I got to complete my SOAP UI request successfully. Feb 20 '20 at 12:26
  • 1
    Done @brian-miller Feb 21 '20 at 9:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.