function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Shiv Shankar 80Shiv Shankar 80 

How can i check Community settings are enable or not using apex?

Hi,

Can anyone help me in this regard.
How can i check Community settings are enable or not using apex?

Thanks in advance.
Prithviraj_ChavanPrithviraj_Chavan
Hi Shiv,
You can do that using Force.com REST API
You need to add your url in remote site setting..
        try{
            Http http = new Http();
            HttpRequest request = new HttpRequest();
            request.setMethod('GET');
            String endpoint = 'url of your instance/services/data/v39.0/connect/organization';
            request.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionId());
            request.setEndpoint(endpoint);        
            HttpResponse response = http.send(request);
            if( response.getStatusCode() == 200 )
                system.debug(response.getBody());
        }catch(Exception Ex){
            System.debug('Error Occurred    ::    '+Ex.getMessage()); 
        }

you can check in response.getbody();