+ Start a Discussion
Tom DJTom DJ 

How to detect if Org has API access from within Apex?

 

Does anyone know if there is a way to detect from Apex code if a Professional Org has bought API access?

 

Thanks in advance,

 

Tom

 

Best Answer chosen by Admin (Salesforce Developers) 
Tom DJTom DJ

 

Not perfect, but it looks like that will have to do.    Thanks a lot for your help.

 

Tom

 

 

All Answers

forecast_is_cloudyforecast_is_cloudy

There is no direct way in Apex to find out if an Org has API enabled. The closest thing you have is the 'PermissionsApiEnabled' field on the Profile object. You can therefore find out if the current user has API enabled for their profile.

Thinking out aloud here, but maybe you can perform a SOQL query to get the 'PermissionsApiEnabled' field on the standard 'System Administrator' profile. If that field is false, you can infer that API is not enabled for the Org? You'll have to try this in a Professional Edition Org to confirm though.

Hope this helps...

Tom DJTom DJ

 

Not perfect, but it looks like that will have to do.    Thanks a lot for your help.

 

Tom

 

 

This was selected as the best answer