function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
rschenkelrschenkel 

Sandbox login failing...

I am an enterprise customer and can log into the production environment through the API.  Today I created a sandbox (I guess developer version) of my production environment.  I am unable to log into the sandbox version.  I logged into the sandbox version through a web portal and generated an sercurity token.  I am using username.sandboxname and passwordtoken.  Here is the code:

 

        private bool Login(string strUsername, string strPassword, string strToken)
        {
            // Timeout after a minute
            _sforceService.Timeout = 60000;

            // Try loggin in
            LoginResult loginResult;
            try
            {
                loginResult = _sforceService.login(strUsername, strPassword + strToken);
            }
            catch (SoapException e)
            {
                return false;
            }

            if (loginResult.passwordExpired)
                return false;

            // Reset the endpoint of the service to the virtual server instance that is servicing our organization
            _sforceService.Url = loginResult.serverUrl;

            // Set the persistent SOAP header.
            _sforceService.SessionHeaderValue = new SessionHeader();
            _sforceService.SessionHeaderValue.sessionId = loginResult.sessionId;
            return true;
        }

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
SuperfellSuperfell

You need to change the host name, but keep the rest of the URL the same, something like xxx.url = "https://test.salesforce.com/services/Soap/c/19.0"

All Answers

SuperfellSuperfell

Did you download a sandbox WSDL and use that, or did you update your code to change the URL for the login request to use test.salesforce.com ?

rschenkelrschenkel

Hi Simon, thanks for the quick reply.  No I could not download the WSDl from the sandbox version... it was trying to generate a google something or other.  Did not respond the same way as production.

 

No I did not change the URL... when I did the following command _sforceService.Url = "test.salesforce.com"; I got a completely different expection.

SuperfellSuperfell

You need to change the host name, but keep the rest of the URL the same, something like xxx.url = "https://test.salesforce.com/services/Soap/c/19.0"

This was selected as the best answer
rschenkelrschenkel

Thanks Simon!