I am currently on the beta for the flexible associations and I am struggling on how can I associate multiple companies to the same contact through the API.
As of now, I can perform the associations with no issues on the UI. However, when I try to replicate the same issue through the API, I am reaching a dead-end.
import hubspot
from hubspot.crm.associations import BatchInputPublicAssociation, ApiException
client = hubspot.Client.create(api_key='api_key')
payload = [{
"from":{"id":"592476"},
"to":[
{"id":"4840447981","type":"contact_to_company"},
{"id":"4840447986","type":"contact_to_company_unlabeled"},
{"id":"4840448191","type":"contact_to_company_unlabeled"},
{"id":"4840448194","type":"contact_to_company_unlabeled"},
{"id":"4840448206","type":"contact_to_company_unlabeled"},
{"id":"4840448220","type":"contact_to_company_unlabeled"},
{"id":"4840448442","type":"contact_to_company_unlabeled"}]}]
batch_input_public_association = BatchInputPublicAssociation(inputs=payload)
try:
api_response = client.crm.associations.batch_api.create(from_object_type="contact", to_object_type="company", batch_input_public_association=batch_input_public_association)
print(api_response)
except ApiException as e:
print("Exception when calling batch_api->create: %s\n" % e)
I am currently getting this error:
message":"Invalid input JSON on line 1, column 46: Cannot deserialize instance of com.hubspot.apiutils.core.models.PublicObjectId$Json out of START_ARRAY token","correlationId":"fbc3fe63-c3be-4f94-8bda-8826111b421f