Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- Import a small set of contacts to Eloqua
- """
- from os import environ
- from pyeloqua import Bulk
- # Initialize Bulk object
- # Here I pass environment variables which contain the necessary information
- # You could also pass strings with username, password, and company
- bulk = Bulk(company=environ['ELOQUA_COMPANY'],
- username=environ['ELOQUA_USER'],
- password=environ['ELOQUA_PASSWORD'])
- # define what action we are taking (import) and what object we are importing to (contacts)
- bulk.imports('contacts')
- # define which fields we are importing
- bulk.add_fields(['C_EmailAddress', 'C_FirstName'])
- # define an identifier field which Eloqua will match on for upsert
- bulk.add_options(identifierFieldName='C_EmailAddress')
- # define a sample set of data to import
- data = [
- {
- 'C_EmailAddress': 'example1@test.com',
- 'C_FirstName': 'tester'
- },
- {
- 'C_EmailAddress': 'example2@test.com',
- 'C_FirstName': 'testing'
- }]
- # Initialize the import
- bulk.create_def('test_import')
- # send import data
- bulk.post_data(data)
- # initialize data sync
- bulk.sync()
- # output will be status of sync
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement