[SalesForce] Calling Rest resource issue from Force.com sites

I have rest resource class which i am calling from force.com site..

Below is my endpoint

https://cs22.force.com/services/apexrest/CustomerData/

  @RestResource(urlMapping='/CustomerData/*')
global without sharing class CustomerInfoDataRest {

  @HttpGet
  global static List<Account> getAccountInfo() {
    //String companyName = RestContext.request.params.get('companyName');
    List<Account> companyList = [ Select ID, Name, personemail, BillingState from Account];


    return companyList;

  }
}

Error i am getting

<Errors><Error><errorCode>FORBIDDEN</errorCode><message>You do not have access to the Apex class named: CustomerInfoDataRest</message></Error></Errors>

I have checked Force.com site profile..I already have permission to the class CustomerInfoDataRest in that profile.

I have API enabled as well on Site profile..I have no idea why i am getting this error..

enter image description here

Best Answer

Few suggestions:

  1. Is there any namespace for you org, if yes use this format for endpoint url: https://cs22.force.com/services/apexrest/mynamespace/CustomerData
  2. Ensure class visibility is enabled for public access settings. i guess you are already doing that.
  3. ensure the site profile has access to account object and account fields referred in the service.
Related Topic