+ Start a Discussion
JLeisseJLeisse 

If logging in via the API, do I need to hard code options for Production and Sandbox separately?

I have an API set up currently to login to Salesforce using 'https://login.salesforce.com/services/Soap/u/34.0'. If I want to have an option to login to a Sandbox, do I need to hard code that URL to 'https://test.salesforce.com/services/Soap/u/34.0'? Or is there another option so I don't have to hard code two different URLs?
Best Answer chosen by JLeisse
James LoghryJames Loghry
How are you calling the API?  Is it from a third party?

No, you can't log in via a single URL that is smart enough to point to either system.  Instead, you'll need to configure the endpoint.  You don't have to hard code it per se, but it should be configurable through either a custom setting or a property depending on how you're calling into Salesforce.

All Answers

James LoghryJames Loghry
How are you calling the API?  Is it from a third party?

No, you can't log in via a single URL that is smart enough to point to either system.  Instead, you'll need to configure the endpoint.  You don't have to hard code it per se, but it should be configurable through either a custom setting or a property depending on how you're calling into Salesforce.
This was selected as the best answer
James LoghryJames Loghry
One approach I typically use for instance, is have two instances of the third party app or service.  One that points to prod, one that points to the sandbox.