1

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

  • Is this webservice public? i couldnt hit it.. its asking me for session id – Pranay Jaiswal Oct 27 '15 at 5:03
  • Is you site hosted on same org ? Are all classes native to you ? Did you tried calling through curl/hurl to test your api ? Read this and this two my blog post to see if you are doing correctly. If problem persist share and lets us know – Harshit Pandey Oct 27 '15 at 7:27
1

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.
1

the problem is your endpoint.

You need use the site url

Example:

SITE URL : mySite.force.com

SERVICE URL SITE : https://mySite.force.com/services/apexrest/CustomerData/

Regards

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.