I’m having an issue pushing an engagement email to a HubSpot account. The crux of the issue is that, although the API calls all succeed, the emails are not visible in the contact’s email engagements list.
I will post the code below, but essentially I have confirmed that the engagement email is successfully created and associated with the contact by subsequently reading back the list of associated emails with the contact, and the email ID is present in the list.
How can it be possible that the API calls all succeed, but then the emails aren’t in the contact’s email list? Any help would be greatly appreciated.
Here’s a snippet of the code I’m using to push the emails, perhaps it will help:
properties = {
"hs_timestamp": email.received_at.isoformat(),
"hs_email_direction": "EMAIL",
"hs_email_status": "SENT",
"hs_email_subject": email.subject,
"hs_email_text": email.body,
"hubspot_owner_id": owner_id,
}
associations = [
{
"to": {
"id": contact.source_id,
},
"types": [
{
"associationCategory": "HUBSPOT_DEFINED",
"associationTypeId": 198, # Email to contact.
},
],
},
]
resp = client.crm.objects.emails.basic_api.create(
SimplePublicObjectWithAssociations(
properties=properties,
associations=associations,
),
)
# The results of this call show the new email's ID in the list.
resp = client.crm.associations.v4.basic_api.get_page(
"contact",
contact.source_id,
"email",
)