daily pastebin goal
36%
SHARE
TWEET

Untitled

a guest Jul 20th, 2017 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. """
  2. Import a small set of contacts to Eloqua
  3. """
  4.  
  5. from os import environ
  6. from pyeloqua import Bulk
  7.  
  8. # Initialize Bulk object
  9. # Here I pass environment variables which contain the necessary information
  10. # You could also pass strings with username, password, and company
  11. bulk = Bulk(company=environ['ELOQUA_COMPANY'],
  12.             username=environ['ELOQUA_USER'],
  13.             password=environ['ELOQUA_PASSWORD'])
  14.  
  15. # define what action we are taking (import) and what object we are importing to (contacts)
  16. bulk.imports('contacts')
  17.  
  18. # define which fields we are importing
  19. bulk.add_fields(['C_EmailAddress', 'C_FirstName'])
  20.  
  21. # define an identifier field which Eloqua will match on for upsert
  22. bulk.add_options(identifierFieldName='C_EmailAddress')
  23.  
  24. # define a sample set of data to import
  25. data = [
  26.   {
  27.     'C_EmailAddress': 'example1@test.com',
  28.     'C_FirstName': 'tester'
  29.   },
  30.   {
  31.     'C_EmailAddress': 'example2@test.com',
  32.     'C_FirstName': 'testing'
  33.   }]
  34.  
  35. # Initialize the import
  36. bulk.create_def('test_import')
  37.  
  38. # send import data
  39. bulk.post_data(data)
  40.  
  41. # initialize data sync
  42. bulk.sync()
  43. # output will be status of sync
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top