Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to connect to Salesforce using RestAPI: INVALID SESSION
    primarykey
    data
    text
    <p>Hi i am trying to connect to Salesforce with the Rest API and i want to retrieve sObjects..Implementing as below</p> <pre><code>void getsObjects() throws IOException { HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost("https://na14.salesforce.com/services/data/v24.0/sobjects"); try { // Add your data List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;(2); nameValuePairs.add(new BasicNameValuePair("X-HostCommonName", "ap1.salesforce.com")); nameValuePairs.add(new BasicNameValuePair("X-PrettyPrint", "1")); nameValuePairs.add(new BasicNameValuePair("Host", "ap1.salesforce.com")); nameValuePairs.add(new BasicNameValuePair("X-Target-URI", "https://ap1.salesforce.com")); nameValuePairs.add(new BasicNameValuePair("Content-Type", "application/json")); nameValuePairs.add(new BasicNameValuePair("Connection", "Keep-Alive")); nameValuePairs.add(new BasicNameValuePair("Authorization", "00D90000000qUEp!AQQAQNnuPZqEX2oqAkeQLmvq.qsBfKIMa3GCJvE7atLv2Cjy94YZn5ezRH0bosXTFthnoMNt.WpDturXB1Ijxxxxxxxxxx")); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); httppost.setHeader("Content-Type","application/json"); // Execute HTTP Post Request HttpResponse response = httpclient.execute(httppost); String result = EntityUtils.toString(response.getEntity()); System.out.println("Final response"+result); } catch (ClientProtocolException e) { // TODO Auto-generated catch block } catch (IOException e) { // TODO Auto-generated catch block } } </code></pre> <p>even if i am passing the the Authorization key , it is giving INVALID SESSION error</p> <pre><code>12-11 14:50:18.108: W/DefaultRequestDirector(27014): Authentication error: Unable to respond to any of these challenges: {token=WWW-Authenticate: Token} 12-11 14:50:18.498: I/System.out(27014): Final response[{"errorCode":"INVALID_SESSION_ID","message":"Session expired or invalid"}] </code></pre> <p>I am trying to connect to it from 2 days but no luck, can someone point me right direction, how to make rest calls.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload