I'm trying to call and test CURL function for REST

  curl -H "Authorization: Bearer sessionId" "https://ap1.salesforce.com/services/apexrest/Account/0019000000xxxxH"

I tried curling with no session ID :)

 [{"message":"Session expired or invalid","errorCode":"INVALID_SESSION_ID"}]

So Curl is properly installed in windows. Where do I get the Session ID?



2 Answers 2

  • Login to salesforce organization

  • Open developer console > execute anonymous

  • Type following line. This gives current logged in user's session ID.:

    SYSTEM.DEBUG('Session Id : ' +Userinfo.getSessionId());

Above is the non-dynamic way to get session id. As you are just testing with cURL so this way will save your time. But i will recommend to read REST API to authenticate and get session Id a.k.a access token dynamically.

  • 2
    This may have worked when it was answered but it no longer works. The debug session says: USER_DEBUG [1]|DEBUG|Session Id : SESSION_ID_REMOVED
    – jimboweb
    Jul 25, 2017 at 20:14

I tried Ashwani's trick. It looks like security removes session id's from logs now. Here's a quick workaround.

SYSTEM.DEBUG('Session Id : ' +Userinfo.getSessionId().reverse())

Then you can just grab it from the log and reverse it again.

You must log in to answer this question.

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