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

Please observe my source code

String orgLimitUrl           = "https://instance.salesforce.com/services/data/v29.0/limits/"

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

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

HttpResponse response = httpClient.execute(getRequest)

if (response.getStatusLine().getStatusCode() != 200) {
    throw new RuntimeException("Failed : HTTP error code : "+ response.getStatusLine().getStatusCode());

BufferedReader br = new BufferedReader(new InputStreamReader((response.getEntity().getContent())))

while ((orgLimitLine = br.readLine()) != null) {


Please help me.

Thanks Anuradha


DO NOT hard code the Salesforce instance.

Salesforce Instance is retrieved when we get access token. In response to login.salesforce.com it provides a json containing accesstoken, instance_url etc. which looks like:


Use that instance_url + /services/data/v29.0/limits/ or any other query path

| improve this answer | |
  • Hi regal,I did according to you told.Its working fine.Thank you so much for helping – Anuradha Feb 17 '14 at 13:43

You have "https://instance.salesforce.com/services/data/v29.0/limits/" as your URL, but there is no such host as instance.salesforce.com, you need to substitute in your real instance name e.g. "https://na13.salesforce.com/services/data/v29.0/limits/" for your API request. If you login via the UI you can see what your instance is there, or if you got your access token via OAuth, the OAuth result also includes it.

| improve this answer | |

Check your endpoint URL. If there is authentication problem, you'll get login exception. See if other integrations in your org are working or if the same exception is thrown. You can contact salesforce support if you can't debug the problem.

| improve this answer | |
  • yes this is only whole error message. – Anuradha Feb 15 '14 at 9:48

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.