+ Start a Discussion
EtienneCoutantEtienneCoutant 

package for Sandbox vs Production

Hi,

 

Is there a way to detect in Apex if the system is a Sandbox or a Dev Edition?

 

Thanks.

 

 

 

 

Happy2HelpHappy2Help

Hi

 

A typical API Server URL in a dev sandbox appears as "https://c.cs3.visual.force.com/services/Soap/c/18.0/00DQ0000000AgYM", where the record ID is ORG ID.

I am generating this API Server URL in my APEX class using "ApexPages.currentPage().getHeaders().get('Host')", which gives the instance server url "c.cs3.visual.force.com". Then I use two other constants to form the actual API Server URL, which is "https://" and "services/Soap/c/18.0".

API Server URL= 'https://'+ 'ApexPages.currentPage().getHeaders().get('Host')' +'services/Soap/c/18.0/'+ORG_ID

 

I think it helps you. :smileyhappy:

michaelforcemichaelforce

I know this thread is pretty old, but I wanted to post in case people find it through search and have the same problem.  I have a solution for this posted on my blog:  http://www.michaelforce.org/recipeView?id=a0Ga000000Ekp65EAB

 

Cheers.