[SalesForce] [{“message”:”limits resource is not enabled”,”errorCode”:”API_DISABLED_FOR_ORG”}]; HTTP Status: 403

I am trying to consume sales force rest api service in my application.At that time,i am getting this exception

[{"message":"limits resource is not enabled","errorCode":"API_DISABLED_FOR_ORG"}]; HTTP Status: 403.

Please observe my source code

            JSONObject orgLimitJo       = new JSONObject()
    String orgLimitUrl          = "/services/data/v29.0/limits/"

    JSONObject accessTokenObj   = getAccessToken()
    String accessToken          = accessTokenObj.access_token
    String instanceUrl          = accessTokenObj.instance_url
    print accessTokenObj.access_token
    StringBuffer orgLimisList   = new StringBuffer()
    String orgLimitLine

    try {

        DefaultHttpClient httpClient = new DefaultHttpClient()
        HttpGet getRequest           = new HttpGet(instanceUrl+orgLimitUrl)

        getRequest.addHeader("Authorization", "Bearer " + accessToken)
        getRequest.addHeader("X-PrettyPrint", "1" )

        HttpResponse response = httpClient.execute(getRequest)      
        BufferedReader br = new BufferedReader(new InputStreamReader((response.getEntity().getContent())))

        while ((orgLimitLine = br.readLine()) != null) {
            orgLimisList.append(orgLimitLine)
        }

        httpClient.getConnectionManager().shutdown()

please help me.
Thanks
Anuradha

Best Answer

You need to have both the API enabled and View Setup and Configuration system permissions enabled. When you miss the API enabled permission you get the error:

API is disabled for this User

When you miss the View Setup and Configuration permission you get the error:

limits resource is not enabled

(at least, that is what I observe when testing against a scratch org using sfdx force:limits:api:display)

Related Topic