+ Start a Discussion
mandycmandyc 

Help finding/retrieving sessionId

I would like to try running the Apex REST Basic Code Sample provided on page 238 of the following doc: http://www.salesforce.com/us/developer/docs/apexcode/salesforce_apex_language_reference.pdf

 

At the bottom of page 238, they list the following instructions for running the sample code except I don't know how to find/retrieve the sessionId.

 

2. To call the doGet method from a client, open a command-line window and execute the following cURL command to
retrieve an account by ID:
curl -H "Authorization: OAuth sessionId"
"https://instance.salesforce.com/services/apexrest/Account/accountId"

• Replace sessionId with the <sessionId> element that you noted in the login response.
• Replace instance with your <serverUrl> element.
• Replace accountId with the ID of an account which exists in your organization.

 

Thank you in advance for your help!

hisrinuhisrinu

You can use userinfo.getSessionId() in order to retrieve the session id of the logged in user