This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.
Configuring Salesforce Operations
To use the Salesforce connector, add the <salesforcerest.init>
operation in your configuration before carrying out any other Salesforce operations.
The Salesforce REST API can use the OAuth2 authentication with access token. For more information on authentication, see https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/quickstart_oauth.html.
Before you start performing various operations with the connector, make sure to import the Salesforce certificate to your ESB client keystore.
Follow the steps below to import the Salesforce certificate into the ESB client keystore:
- Go to your Salesforce account (e.g.,https://ap2.salesforce.com), and click the lock icon on the address bar to view the certificate.
- Have a look at the certificate details and export the certificate to the file system.
Import the certificate into the ESB client keystore via the Management Console or by running the following command.
keytool -importcert -file <certificate file> -keystore <ESB>/repository/resources/security/client-truststore.jks -alias "SFDCCertImport"
- Restart the server and deploy the Salesforce configuration. In this case, you can define the registry path where you can store the variables, then use the
init
operation with defining registry path to configure the Salesforce REST connector.
In this connector we have two flow to get the accessToken. First one is the Web Server OAuth Authentication Flow and the other one is Username-Password OAuth Authentication Flow.
<salesforcerest.init> <accessToken>{$ctx:accessToken}</accessToken> <apiUrl>{$ctx:apiUrl}</apiUrl> <clientId>{$ctx:clientId}</clientId> <clientSecret>{$ctx:clientSecret}</clientSecret> <refreshToken>{$ctx:refreshToken}</refreshToken> <hostName>{$ctx:hostName}</hostName> <apiVersion>{$ctx:apiVersion}</apiVersion> <registryPath>{$ctx:registryPath}</registryPath> <intervalTime>{$ctx:intervalTime}</intervalTime> </salesforcerest.init>
Properties
apiVersion
: The version of Salesforce API.accessToken
: Value of the access token to access the API via request.apiUrl
: The instance URL for your organization.refreshToken
: Value of the refresh token.clientId
: Value of your client ID given when you registered your application with Salesforce.clientSecret
: Value of your client secret given when you registered your application with Salesforce.hostName
: SalesforceOAuth endpoint when issuing authentication requests in your application.intervalTime
: The Interval time in milliseconds to check the access token validity.registryPath
: Registry path of the connector where the values are stored. You must give the value as :connectors/<value>
For example:registryPath = "connectors/salesforcerest".
Sample request
Following is a sample REST request that can be handled by the init
operation.
{ "clientId": "3MVG9ZL0ppGP5UrBztM9gSLYyUe7VwAVhD9.yQnZX2mmCu_48Uwc._doxrBTgY4jqmOSDhxRAiUBf8gCr2mk7", "refreshToken": "5Aep861TSESvWeug_ztpnAk6BGQxRdovMLhHso81iyYKO6hTm6kHoL4.YfwIi9cHLwga.pPTsTuJlmKjo05x.o.", "clientSecret": "1187341468789253319", "hostName": "https://login.salesforce.com", "apiVersion": "v32.0", "registryPath":"connectors/salesforcerest", "accessToken":"00D280000017q6q!AQoAQOeXcp7zKo3gUdy6r064_LsJ5bYYrUn_qAZG9TtKFLPfUMRxiato.E162_2XAtCTZLFQTbNk2Rz6Zm_juSakFE_aaBPp", "intervalTime" : "100000", "apiUrl":"https://ap2.salesforce.com" }
Related documentation
<salesforcerest.init> <apiUrl>{$ctx:apiUrl}</apiUrl> <clientId>{$ctx:clientId}</clientId> <clientSecret>{$ctx:clientSecret}</clientSecret> <hostName>{$ctx:hostName}</hostName> <apiVersion>{$ctx:apiVersion}</apiVersion> <username>{$ctx:username}</username> <password>{$ctx:password}</password> </salesforcerest.init>
Properties
apiUrl
: The instance URL for your organization.clientId
: The value of your client ID given when you registered your application with Salesforce.clientSecret
: The Value of your client secret given when you registered your application with Salesforce.hostName
: SalesforceOAuth endpoint when issuing authentication requests in your application.apiVersion
: The version of Salesforce APIusername
: The username for the salesforce.password
:The password for the salesforce (Need to append the password with security key).
Following is a sample REST request that can be handled by the init
operation for username and password flow.
{ "clientId": "3MVG9ZL0ppGP5UrBztM9gSLYyUe7VwAVhD9.yQnZX2mmCu_48Uwc._doxrBTgY4jqmOSDhxRAiUBf8gCr2mk7", "clientSecret": "xxxxxxxxxxxxxxxxxxxxxxxx", "hostName": "https://login.salesforce.com", "apiVersion": "v32.0", "username": "tharis63@outlook.com", "password": "xxxxxxxxxxxxxxxxxxxxxx", "apiUrl":"https://ap2.salesforce.com" }
Related documentation
Next steps
Now that you have connected to Salesforce, use the information in the following topics to perform various operations with the connector. Also, see Configuring the Salesforce REST API Connector Fault Handler Sequence.
- Working with AppMenu
- Working with Approvals
- Working with Event Monitoring
- Working with Invocable Actions
- Working with Layouts in Salesforce
- Working with List Views
- Working with Process Rules
- Working with Queries
- Working with Quick Actions
- Working with Records
- Working with Salesforce Users
- Working with Search
- Working with sObjects