Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way for me to get salesforce instance URL from Java?

I was looking for something similar to System.Url.getSalesforceBaseUrl() in Apex, but I couldn't find anything suitable in Metadata or SOAP API.

share|improve this question
up vote 5 down vote accepted

When you call the Partner API login() method it will return a LoginResult. It will have the:

  • serverUrl

    URL of the endpoint that will process subsequent API calls. Your client application needs to set the endpoint.

and

  • metadataServerUrl.

    URL of the endpoint that will process subsequent metadata API calls. Your client application needs to set the endpoint.

If you already have the serverUrl then you can just take the domain part of it.

share|improve this answer
    
Thank you, this is what I was looking for. Let me do some tweaks in my code – currently, when I do 'login()', 'PartnerConnection' is returned instead of 'LoginResult'... – wintermute yesterday

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.