Last active
February 10, 2023 13:47
-
-
Save colemanja91/532a269eaaa09ef9e3c2a8984bf69bb8 to your computer and use it in GitHub Desktop.
Basic pyeloqua import
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
NOTICE: I no longer support pyeloqua-related code, I have not worked in Eloqua since 2017 and the APIs have likely changed since then | |
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': '[email protected]', | |
'C_FirstName': 'tester' | |
}, | |
{ | |
'C_EmailAddress': '[email protected]', | |
'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 |
I find this helpful, given the fact that there is hardly any example of pyeloqua module's use over the internet. Thank you
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for the API. I need to import new contacts/data to contact List. I'm unable to import into that. Can you please help me in that.