0

help me out to go forward in salesforce integration with java using REST API.

These are the steps i came across and unable to find the way.

  1. Post a request to login.salesforce.com through REST client using my client_id and client_secret and username and password along with user's security token.

https://login.salesforce.com/services/oauth2/token?grant_type=password&client_id{}&client_secret={}&username={}&password={}{}

I got the response from salesforce along with access_token as follows :

{
id: "https://login.salesforce.com/id/{}"
issued_at: "{}"
token_type: "Bearer"
instance_url: "{}"
signature: "{}"
access_token: "{}"
}
  1. Till now i am getting proper response. Now i am using the curl operation to get the available objects with the instance_url and access_token.

curl https://{}.salesforce.com/services/data/v31.0/ -H "Authorization: Bearer {access_token}"

Here i am getting the response as follows :

[{"message":"Session expired or invalid","errorCode":"INVALID_SESSION_ID"}]

Same response getting for different versions and for different instance_url.

Can you please shed some light on this issue and help me???

8
  • 1
    Are you literally using "Bearer: {}" as your authorization in the CURL command? Because sessionID should be something like a 112 character string.
    – Doug B
    Oct 8, 2014 at 9:17
  • No Doug B. I am passing the access_token like this : "Authorization: Bearer 00090sdsad\!KAgaraKa7887dsaasdA_3242Fdsda" Oct 8, 2014 at 9:50
  • If you repeat step 1 and use the new access token, does it work?
    – metadaddy
    Oct 8, 2014 at 14:06
  • No.. If i repeat the step1 the access_token will be updated/changed. I have used that updated token in the curl command but still i am getting the same response. I even tried with adv. REST client extension in chrome also but the response was same. Oct 8, 2014 at 15:23
  • Not 100% sure if this is helpful, but i've just tried doing the same curl with our SF instance and it worked fine... I only had to change double quotes into single quotes around the header string because my token included exclamation point: curl na10.salesforce.com/services/data/v31.0 -H 'Authorization: Bearer 00DF0000000gR6k!...WS' Oct 8, 2014 at 19:42

1 Answer 1

1

after a long trial, i succeeded in getting the proper response.

Hit through the rest-client chrome extension by passing URL and giving the Authorization: Bearer 00D9..........................................................Daar787@asU in the headers list would give you the result as a response.

1
  • Hi I am trying to do integration of salesforce with Java using Reat Api using the follwing link but i did not find the proper files on the Java side project set up with the links given in this documentation ( developer.salesforce.com/page/… ) , Could you please share the documentation you followed to implement this.
    – Suresh
    Apr 7, 2015 at 14:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .