# Trouble assigning a contact to a task - HubSpot Python package

**URL:** <https://community.hubspot.com/t/trouble-assigning-a-contact-to-a-task-hubspot-python-package/72916>\
**Category:** APIs & Integrations\
**Tags:** contacts\
**Created:** [January 15, 2023, 11:40am UTC](https://community.hubspot.com/t/trouble-assigning-a-contact-to-a-task-hubspot-python-package/72916 "2023-01-15T11:40:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![merc1er](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/merc1er/32/197196_2.png) [@merc1er](https://community.hubspot.com/u/merc1er)\
**Post date:** [January 15, 2023, 11:40am UTC](https://community.hubspot.com/t/trouble-assigning-a-contact-to-a-task-hubspot-python-package/72916/1 "2023-01-15T11:40:43Z")

</div>

I am creating a task with the [Hubspot Python package](https://github.com/HubSpot/hubspot-api-python), and am trying to assign it a contact.

However, I am having trouble assigning the contact and am getting the error:

```auto
{"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:

```auto
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.

---

<div class="post-metadata">

**Author:** ![merc1er](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/merc1er/32/197196_2.png) [@merc1er](https://community.hubspot.com/u/merc1er)\
**Post date:** [January 14, 2023, 11:45am UTC](https://community.hubspot.com/t/trouble-assigning-a-contact-to-a-task-hubspot-python-package/72916/2 "2023-01-14T11:45:12Z")

</div>

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:

```lia-code-sample
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.

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [January 17, 2023, 7:25pm UTC](https://community.hubspot.com/t/trouble-assigning-a-contact-to-a-task-hubspot-python-package/72916/3 "2023-01-17T19:25:05Z")

</div>

Hey, @merc1er 👋 Did you get unstuck here? If not, I am happy to spn up a quick example and tag a few community members to help as needed.

Best,

Jaycee

---

<div class="post-metadata">

**Author:** ![merc1er](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/merc1er/32/197196_2.png) [@merc1er](https://community.hubspot.com/u/merc1er)\
**Post date:** [February 13, 2023, 5:14am UTC](https://community.hubspot.com/t/trouble-assigning-a-contact-to-a-task-hubspot-python-package/72916/4 "2023-02-13T05:14:05Z")

</div>

No. Thank you!

Basically i’d like to know if there’s a list of “ObjectTypes” and “ObjectTypeIds”.
