You need to sign in to do that
Don't have an account?
Getting serverURL for api calls
I'm trying to get the server url in apex code to pass it (and the sessionId) to a web service outside salesforce to make API calls. I've read this post and changedthe visualforce parameter to "$Api.Enterprise_Server_URL_180" but this is giving me the following url: https://c.na7.visual.force.com/services/Soap/c/18.0/{ORGId}.
There is no way I can access the api with that url, it should be something like:
https://na7-api.salesforce.com/services/Soap/c/18.0/{ORGId}
So is there a way to get the real serverURL? Or am I supposed to parse that first url to create the second one? (This wouldn't be very elegant).
Thanks in advance;
Farid
this is something that i found out while doing some research...havent implemented it...
http://blog.sforce.com/sforce/2009/01/accessing-session-id-and-api-server-url-parameters-with-visualforce.html
apart from that i faced the same issue earlier....i did it using both $API and ApexPages.currentPage().getHeaders().get('Host')
but i had to do the parsing to get the actual url...the reason is that i was trying to get the url from a visual force page, and when you load a page its url is always given as c.instancename.visua.force.com/......