1

I've created a REST web service on Salesforce and exposed it as a public service (Using Sites). Now I am consuming this service from an external web site. I need to get the Salesforce base URL inside this web service code to populate a URL. I used,

String baseUrl = System.URL.getSalesforceBaseUrl().toExternalForm();

When I call the web service from the external site, this returns always the custom URL I added for the site (Web Service), but not the real base URL which I see when I logged in to the Org.

I need to get the actual base URL which I see when I logged in to my Org. Appreciate your support.

  • I think it's better for you to hold the URL for specific org in a custom setting and change it according base of the ORG. If it work, please mark as right Answer! – Virath C. Liyanage Sep 13 '17 at 5:56
-1

I think it's better for you to hold the URL for specific org in a custom setting and change it according base of the ORG.

If it works, please mark as right Answer!

  • Yes this approach works, But my client wants to use a dynamic way. He does not want to update the custom settings once deployed to Production. – Dinesh Wickramasinghe Sep 20 '17 at 9:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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