In the past i implemented following example
http://developer.force.com/cookbook/recipe/verifying-password
in order to login a user via API:
I've exactly same code and it worked for 1year.
Now it s not working anymore, response call is:
HttpResponse[Status=Server Error, StatusCode=500]
I m wondering if something (endpoint, request format) has changed with Winter 15 release.
Do you know something about?
Best Answer
I suspect the issue is around the security token and the Trusted IP Ranges in the Network Access Security Controls.
Something to check, look for failed logins under
Administration Setup > Manage Users > Login History
. If you see the Status message "Failed: API security token required" then the requesting Salesforce IP address isn't trusted.If the IP address that the login request is coming from isn't trusted Salesforce will reject it unless you append the security token on the end of the password.
So your options are:
Administration Setup > Securtiy Controls > Network Access: Trusted IP Ranges
. You could also check Salesforce IP Address to whitelistThis isn't so applicable anymore, but does provide a sample working version from anonymous apex
It would appear that the sample code isn't building a valid SOAP POST request for the partner API. In particular, it is missing the body element. I modified the way the XML is created and got it working.The request body should look something like:
Here is the hastily modified login Soap message. Note the additional XML declaration
and Body plusHeader elements in thexmlOutput
.