1

The question can also be viewed as: how to obtain sessionID without oAuth?

Since, here we would need to query from any Salesforce org using Username and password, we can not use oAuth(which would need to be set in each org we would like to query)

and, since we are querying from Salesforce, we do not have a Apex Login method to get the SessionID

How to query Custom Setting from one Salesforce Org, by using just UserName and Password?

  • I too had the same problem when I had to query few data from API user through back-end. The answer below helped me and I am using the below piece of code in all the places where I require SessionId. – karthikselva Feb 15 '16 at 10:54
0
  • Use SOAP login API to obtain Salesforce SessionId as below

     curl https://login.salesforce.com/services/Soap/u/36.0 
     -H "Content-Type: text/xml; charset=UTF-8" 
     -H "SOAPAction: login" 
     -d @login.txt
    
  • @login.txt should contain content as below:

    <?xml version="1.0" encoding="utf-8" ?> <env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"> <env:Body> <n1:login xmlns:n1="urn:partner.soap.sforce.com"> <n1:username>your_username</n1:username> <n1:password>your_password</n1:password> </n1:login> </env:Body> </env:Envelope>

Ref: https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/asynch_api_quickstart_login.htm

  • could you please share the equivalent in Apex or JavaScript? – San Tosh Feb 16 '16 at 8:46

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.