I am creating a task with the Hubspot Python package, and am trying to assign it a contact.
However, I am having trouble assigning the contact and am getting the error:
{"status":"error","message":"One or more associations are invalid","correlationId":"74f11757-cf08-40e0-8ea4-b476fa7c7f32","context":{"INVALID_OBJECT_IDS":["CONTACT=15447877061 is not valid"]},"category":"VALIDATION_ERROR"}
Here is my code:
from hubspot import HubSpot
from hubspot.crm.tickets import SimplePublicObjectInput
# Create a task.
properties = {
"hs_timestamp": current_utc_time,
"hs_task_body": body,
"hubspot_owner_id": secrets["hubspot_owner_id"],
"hs_task_subject": subject,
"hs_task_status": "WAITING",
"hs_task_priority": "HIGH",
}
simple_public_object_input = SimplePublicObjectInput(properties=properties)
task = hubspot.crm.objects.tasks.basic_api.create(
simple_public_object_input=simple_public_object_input
)
# Assign it a contact.
hubspot.crm.objects.tasks.associations_api.create(
task_id=task.id,
to_object_type="Contact",
to_object_id=101, # example contact ID. The contact 101 exists in my env.
association_spec=[
{
"associationCategory": "HUBSPOT_DEFINED",
"associationTypeId": 1, # what is this supposed to be?
}
],
)
It seems to think my task ID is my contact ID..? I am also confused by the associationTypeId. What is it supposed to be? In the docs it is always 0 with no explanation of what it is (as far as I could see). It seems I am missing/not understanding something here. Thank you.
I am creating a task with the Hubspot Python package, and am trying to assign it a contact.
However, I am having trouble assigning the contact and am getting the error :
{"status":"error","message":"One or more associations are invalid","correlationId":"74f11757-cf08-40e0-8ea4-b476fa7c7f32","context":{"INVALID_OBJECT_IDS":["CONTACT=15447877061 is not valid"]},"category":"VALIDATION_ERROR"}
Here is my code:
from hubspot import HubSpot
from hubspot.crm.tickets import SimplePublicObjectInput
# Create a task.
properties = {
"hs_timestamp": current_utc_time,
"hs_task_body": body,
"hubspot_owner_id": secrets["hubspot_owner_id"],
"hs_task_subject": subject,
"hs_task_status": "WAITING",
"hs_task_priority": "HIGH",
}
simple_public_object_input = SimplePublicObjectInput(properties=properties)
task = hubspot.crm.objects.tasks.basic_api.create(
simple_public_object_input=simple_public_object_input
)
# Assign it a contact.
hubspot.crm.objects.tasks.associations_api.create(
task_id=task.id,
to_object_type="Contact",
to_object_id=101, # example contact ID. The contact 101 exists in my env.
association_spec=[
{
"associationCategory": "HUBSPOT_DEFINED",
"associationTypeId": 1, # what is this supposed to be?
}
],
)
It seems to think my task ID is my contact ID..? I am also confused by the associationTypeId. What is it supposed to be? In the docs it is always 0 with no explanation of what it is (as far as I could see). It seems I am missing/not understanding something here. Thank you.