Syncing contacts from Google Cloud Storage to Salesforce
Code
Set your Polytomic API key as an environment variable:
This example covers five steps:
- Create a Salesforce connection.
- Create a Google Cloud Storage connection.
- Verify the connections are ready.
- Create a model over a Google Cloud Storage CSV file.
- Sync the model to Salesforce Contacts.
1. Create a Salesforce connection
The following request creates a Salesforce Connection through the Create Connection endpoint. For end-user onboarding, prefer Polytomic Connect’s embedded auth.
cURL
Python
Typescript
Go
Salesforce Connections authenticate with OAuth. Open the URL returned in the auth_url field of the response to complete the flow.
OAuth redirection
By default, the API expects auth_url to open in a new browser window.
Set the optional redirect_url parameter in the request body to change
the redirect target.
2. Create a Google Cloud Storage connection
The following request creates a Google Cloud Storage Connection.
cURL
Python
Typescript
Go
3. Verify connection readiness
Before syncing, poll the Get Schema Status endpoint for each Connection ID until cache_status is true. Once it is, the Connection’s schema is ready to query.
4. Create a source model over the GCS CSV
Next, create a model over a CSV file in Google Cloud Storage (GCS). A model is a view — a collection of fields you can sync to other systems in whole or in part.
Call the Create Model endpoint to expose every column in high_paying_users.csv:
cURL
Python
Typescript
Go
5. Sync the GCS model to Salesforce Contacts
The sync maps email on the GCS model to the Email field on Salesforce Contacts, and also maps first_name and last_name. Add more entries to the fields array to sync additional columns.
Listing target objects
To discover the target objects available on a destination, use the Get Sync Target Objects endpoint.
Creating the sync
Create the sync with the Create Sync endpoint.
