Access Apex Rest API Salesforce from TalenD

images

Hello Readers,

This is our follow post on Talend Interview Questions, below are the all required steps to access Salesforce data using your own Talend Instance using APEX REST API.

Step 1

In SF go to Setup, Create, Apps. Scroll to bottom of page where it says Connected apps and click new by visiting the given url

https://www.salesforce.com/us/developer/docs/api_rest/Content/intro_understanding_authentication.htm

Access Apex Rest API Salesforce from TalenD

Access Apex Rest API Salesforce from TalenD

 

Name can be anything as long as you know what it is, callback URL does not really matter, but use same as example. The important thing is selecting the Access and Manage Your data in scopes.

Step  2

After you create it, Consumer Key and Consumer Secret Values are what you use in Call to OAUTH API. Please see the screenshot below.

Access Apex Rest API Salesforce from TalenD

Access Apex Rest API Salesforce from TalenD

 

Step 3

After setting up the Connected App in Salesforce, we need to make a call to OAUth API to get token i.e access token. For making the call we need to have cURL installed. There may be other options but I prefer cURL.

 Step 4

One can download the cURL with SSL for one’s OS  and the required certificate of it from the below link https://support.zendesk.com/hc/en-us/articles/203691436-Installing-and-using-cURL

Step 5

Create a cURL folder on your machine and move the cURL.exe and its certificate to that folder. Setup “Path” environment variable of it so that cURL can be accessed from anywhere in command prompt. Please see the screenshot below.

Access Apex Rest API Salesforce from TalenD

Access Apex Rest API Salesforce from TalenD

 

 

Step 6

Once the cURL is setup, run the below mentioned command in command prompt to get the access token mentioned in Step 3.

curl –data “grant_type=password&client_id=<insert consumer key here>&client_secret=<insert consumer secret here>&username=<insert your username here>&password=<insert your password and token here>” -H “X-PrettyPrint:1” https://test.salesforce.com/services/oauth2/token

Response of this would be something like this

{

  “id” : “https://test.salesforce.com/id/00Dc0000003txdzEAA/005D0000001wi7EIAQ”,

  “issued_at” : “1421777842655”,

  “token_type” : “Bearer”,

  “instance_url” : “https://<instance>.salesforce.com”,

  “signature” : “AJjrVtbIpJkce+T4/1cm/KbUL7d4rqXyjBJBhewq7nI=”,

  “access_token” : “00Dc0000003txdz!ARQAQHJEpvN8IcIYcX8.IfjYi0FJ6_JFICLcMk6gnkcHdzMF1DYd2.ZW9_544ro7CnCpO4zzPmkgQ7bE9oFd8yhBALGiIbx7”

}

Step 7

Use the “access_token” value in tRESTClient in “Bearer Token”. Please see the screenshot below.

Access Apex Rest API Salesforce from TalenD

Access Apex Rest API Salesforce from TalenD

 

 Step 8

Use 2 tLogRow components, one for showing the success result and the other for displaying any error thrown. Please see the screenshot below

Capture

 

Step 9

Execute the job and you see result as below

Capture

 

Thank you very much for reading the article!!!

Please feel free to post your comments.