Syncing contacts from Google Cloud Storage to Salesforce
Code
Before getting started make sure to set your Polytomic API key as an environment variable:
This example tutorial covers five steps:
- Connecting to Salesforce.
- Connecting to Google Cloud Storage.
- Verifying connection readiness.
- Creating a Google Cloud Storage CSV data model.
- Create a Contacts sync from Google Cloud Storage to Salesforce.
1. Create a Salesforce connection
The following request will create a Salesforce connection using the Create Connection endpoint (you should consider using Polytomic Connect’s embedded auth as an easier alternative).
cURL
Python
Typescript
Go
Since Salesforce connections use OAuth to authenticate, we’ll need to follow the link returned in the auth_url parameter in the response.
OAuth Redirection
By default, the API expects the auth_url to be opened in a new browser window. If you’d like to modify the redirect behavior, there is an optional redirect_url parameter that can be added to the request body.
2. Create a Google Cloud Storage connection
The following request will create a Google Cloud Storage connection.
cURL
Python
Typescript
Go
3. Verify connection readiness
Before using either connection for syncing, verify that the Get Schema Status call for each connection ID returns cache_status = true (you can poll the endpoint until you see this).
When this value is set to true, the connections’ schemas are ready to be interrogated.
4. Create a Google Cloud Storage source CSV data model
We will now create a data model from a CSV file on Google Cloud Storage (hereafter referred to as ‘GCS’). Data models are collections of fields (i.e. views) from which you can select any subset to sync to other systems.
We will use the Create Model endpoint to surface all columns from a high_paying_users.csv file on GCS:
cURL
Python
Typescript
Go
5. Create a sync from the above GCS model to Salesforce Contacts
This sync maps the email field from the GCS CSV model to the Email field of Salesforce Contacts. It additionally maps the first_name and last_name fields from the GCS CSV model. The field mappings can be extended to sync additional fields.
Enumerating destination objects
To list the destination objects to sync to, use the Get Sync Target Objects endpoint.
Creating a sync from your GCS CSV model to Salesforce Contacts
We will now build a sync from the GCS CSV model to Salesforce Contacts using the Create Sync endpoint.
