SOAP API is not able to authenticate using username/password+security only on sandboxes.
I tried to authenticate the username/pwd+Security token using mavens mate and they seem to be correct.
Could this be due to TSL disablement? If so, what is the fix for this? I see fixes around using appropriate Java versions to support this change, but what should I do from Apex to allow SOAP logins?I am getting '
Web service callout failed: WebService returned a SOAP Fault:
INVALID_LOGIN: Invalid username, password, security token; or user
locked out. faultcode=INVALID_LOGIN faultactor=' exception which does
not give any hint about the TLS disablement.
partnerSoapSforceCom.Soap con = new partnerSoapSforceCom.Soap();
partnerSoapSforceCom.LoginResult loginResult = con.login('username', 'passwordtoken');
Please note that it is happening only for sandboxes and not production.
Any ideas, appreciated.
Best Answer
From the example code you provided, it looks like you are accessing the SOAP Partner API from Apex generated via wsdl2apex.
You will need to adjust the initial endpoint of the login call for a sandbox. Sandbox logins need to go via
test.salesforce.com
. All others (except preproduction) start with login.salesforce.com.After you complete the login, use the
serverUrl
from the login result to set the endpoint.