EDIT: for some reason I'm unable to upload the image, so here is the screen shot of my workbench https://ibb.co/kVbpYQ

I get the sessionID from Developer Console annoy window:

System.debug(UserInfo.getOrganizationId().substring(0, 15) + ' ' +  UserInfo.getSessionId().substring(15));

Content-Type: application/json; charset=UTF-8 Accept: application/json X-SFDC-Session: 00Df40000001rBD !AQMAQPQ1fBfn.9_LXIPuJWrY.W0p9BB09Yojr17cQcbQ_RW_JbwkCUSNBR.LryJGm2G0rd9FWvuRKEPRHSJVTnJ.KK0D5hLH


exceptionMessage: Invalid session id

Request Body:

      "Name" : "Sample Bulk API Account 1 (batch 1)"
      "Name" : "Sample Bulk API Account 2 (batch 1)"
      "Name" : "Sample Bulk API Account 3 (batch 1)"
      "Name" : "Sample Bulk API Account 4 (batch 1)"
  • Can you check this answer: salesforce.stackexchange.com/questions/129373/… Commented Jul 1, 2017 at 20:37
  • Did you remove the space in the session id that debug produces?
    – Eric
    Commented Jul 1, 2017 at 21:11
  • 1
    The workbench should already be using the session that came from logging in. You wouldn't ordinarily need to provide one yourself.
    – sfdcfox
    Commented Jul 1, 2017 at 21:33

2 Answers 2


I figured out! for security reasons sessionId was not showing if you just have something like this:

System.debug( UserInfo.getSessionId());

you will get the following:


if you need handy sessionID then you have to do the following:

System.debug(UserInfo.getOrganizationId().substring(0, 15) + '***' +  UserInfo.getSessionId().substring(15));

your sessionId is after the *** just to differentiate from OrgId to sessionId

Hope this help others.


It looks like you are using my work around from Session_ID_Remove Issue in API callouts in Salesforce.

// Remove the intermediate space to get the actual Session ID.
System.debug(UserInfo.getOrganizationId().substring(0, 15) + ' ' +  UserInfo.getSessionId().substring(15));

As I mentioned there, there intermediate space needs to be removed to restore the valid Session ID. You can of course use any other separator characters you choose. Just make sure you remove them before trying to use the Session ID.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .