I am new to AC API. So here is how I got this done.
My question: Is there a more straight forward approach vs the next:
- Create a template of the fields (to get the correct order).
# This is the top list
contacts_hard_template = {
'General Details': ['First Name', 'Last Name', 'Email', 'Phone', 'Account', 'Job Title']
}
# Followed by fieldsValues that fit into General Details ordered by field ordernum
# Followed by Score - these two are configured in my system
score_hard_template = {
'General Details': ['Newsletter Engagement Score', 'Site Visit Score']
}
# Followed by
fieldsValues that fit into all other group ordered by field ordernum
Having the template in correct order, I can then populate all the fields referencing it by group-name key and just fill the next contact as retrieved from API.
Thanks to community I was also able to find a couple of undocumented endpoints that helped me get the field groups using groupMembers and groupDefinitions endpoints.
As a result the python script produces pandas DataFrame with all contacts data that I can then save to excel. Having all data in an excel for all 1000+ clients helps review all the data at once and spot missing fields which we are doing as part of data migration to AC.