December 28, 2018

How to get session id in Salesforce?

1. Use POST method.

2. Set the end point.

Sandbox - https://test.salesforce.com/services/Soap/u/35.0
Production - https://login.salesforce.com/services/Soap/u/35.0

Use custom domain URL if my domain is enabled and prevent login from test or login.salesforce.com is enabled.

3. Set your headers as below.

SOAPAction = ""
Content-Type = text/xml



4. Use the below as body.

  1. <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:partner.soap.sforce.com">  
  2.   
  3.    <soapenv:Body>  
  4.   
  5.       <urn:login>  
  6.   
  7.          <urn:username>Login ID</urn:username>  
  8.   
  9.          <urn:password>Password</urn:password>  
  10.   
  11.       </urn:login>  
  12.   
  13.    </soapenv:Body>  
  14.   
  15. </soapenv:Envelope>  


5. Get the SessionId.


No comments:

Post a Comment