My posts about my jobs and hobbies in computer technology: web development (Java, PHP, jQuery, Angularjs, CSS, HTML, XML, web services), mobile development (Android, PhoneGap), system admin/devops (Linux, CentOS, Apache, Tomcat, MySQL, PostgreSQL, Puppet), open sources...
Thursday, March 3, 2016
Access Salesforce REST API from Talend Open Studio
Today I have a task to pull report data from Salesforce REST API into MySQL database. I've used Talend Open Studio to sync daily Salesforce's modules into Postgresql or replicate MS SQL database into Postgresql before so looks like this task is not difficult. It turned out the Salesforce REST API now requires OAuth 2.0, so I googled to find out how to do that and got this http://www.deepinopensource.com/access-apex-rest-api-salesforce-from-talend/ . The problem is this guide's using cURL to get access_token to enter manually into tRESTClient while I need to do it automatically for daily auto-sync.. So I learned more about Talend's components.. (found it's very powerful!). Here is my solution: use one tRESTClient to request an access token first to assign into context variable, then execute another tRESTClient to access Salesforce REST API with that token.
Below are screenshots.
1. Request a token
2. Extract the token from output
3. Assign token into context variable
4. Use that token for REST
5. Because the Salesforce REST output contains special node name that causes invalid parsing so replace it with a common character