1

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

Error:

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/… – Santanu Boral Jul 1 '17 at 20:37
  • Did you remove the space in the session id that debug produces? – Eric Jul 1 '17 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 Jul 1 '17 at 21:33
1

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:

DEBUG|SESSION_ID_REMOVED

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.

0

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.

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.