Make API Calls to Salesforce from Workflow
Configurations and credentials for making API calls to Salesforce are different from typical API calls. You need to create a connected app in Salesforce and obtain additional credentials.
Prerequisites
- Ensure you have an account on the developer edition of Salesforce. If you don't have an account, sign up at https://developer.salesforce.com/signup.
- Ensure your workflow includes a callout task for invoking API calls to Salesforce endpoints.
- Optional: Zuora recommends that you create global constants for the Salesforce user name and password, so that you do not need to manually enter the credentials every time you create a callout task to Salesforce endpoints.
To learn about how to define and reference global constants, see Global Constants of Workflow.
Procedure
- Create a connected app for the integration in the Salesforce developer edition. If you already have a connected app created for the integration with Workflow, skip this step.
- In Salesforce, select Create > Apps under Build.
- In the Connected Apps section, click New.
- On the page that opens, specify information for the app. Ensure Enable OAuth Settings is selected.
- Click Save.
- When the app is created, click the app name in the Connected Apps section to view its details. Copy the Consumer Key and Consumer Secret to a separate place. We will need them for the authentication configuration in the callout task in Workflow.
You can also define global constants for the Consumer Key and Consumer Secret. - Edit the callout task in your workflow. In the Authentication tab, specify the following authentication details.
- Authentication Type: Select oauth_2.0.
- Grant Type: Select Password Credentials.
- URL: Enter the Salesforce login URL.
- Client ID: Enter the Consumer Key obtained in step 2 or the global constant for Consumer Key.
- Client Secret: Enter the Consumer Secret obtained in step 2 or the global constant for Consumer Secret.
- Token URL: Enter the Salesforce endpoint for token requests.
- Username: Enter your Salesforce user name or the global constant for the user name.
- Password: Enter your Salesforce account password or the global constant for the password.
- In the Headers tab of the callout task, specify the HTTP method and the endpoint URL in its full form (for example, https://na46.salesforce.com/services/data/v45.0/query/?q=select id, name from account), and add the following header:
Key: Content-type
Value: application/json - Save the settings and start the workflow.