I try to create a new contact and to associat this contact with an existing company ID.
Here is my code :
$contactInput = new \HubSpot\Client\Crm\Contacts\Model\SimplePublicObjectWithAssociations();
$contactInput->setProperties([
‘salutation’ => $genre1,
‘lastname’ => $nom1,
‘firstname’ => $prenom1,
‘job_function’ => $fonction1,
‘phone’ => $tel1,
‘mobilephone’ => $mobile1,
‘email’ => $email1
]);
$contactInput->setAssociations([
‘to’ => [‘id’ => $idsociete],
‘types’ => [‘associationCategory’ => “HUBSPOT_DEFINED”, ‘associationTypeId’ => 279]
]);
$contact = $hubspot->crm()->contacts()->basicApi()->create($contactInput);
AND here is the error message :
Fatal error: Uncaught HubSpot\Client\Crm\Contacts\ApiException: [400] Client error: `POST https://api.hubapi.com/crm/v3/objects/contacts\` resulted in a `400 Bad Request` response: {“status”:“error”,“message”:"Invalid input JSON on line 1, column 278: Cannot deserialize value of type `java.util.Array (truncated…) in /homepages/15/d475713241/htdocs/code-events-tools/SETT24/vendor/hubspot/api-client/codegen/Crm/Contacts/Api/BasicApi.php:393 Stack trace: 0 /homepages/15/d475713241/htdocs/code-events-tools/SETT24/vendor/hubspot/api-client/codegen/Crm/Contacts/Api/BasicApi.php(369): HubSpot\Client\Crm\Contacts\Api\BasicApi->createWithHttpInfo() 1 /homepages/15/d475713241/htdocs/code-events-tools/SETT24/api_hubspot.php(275): HubSpot\Client\Crm\Contacts\Api\BasicApi->create() #2 {main} thrown in /homepages/15/d475713241/htdocs/code-events-tools/SETT24/vendor/hubspot/api-client/codegen/Crm/Contacts/Api/BasicApi.php on line 393
Can you help me to fix this?