# API: Cant add contact associations on PHP

**URL:** <https://community.hubspot.com/t/api-cant-add-contact-associations-on-php/70968>\
**Category:** APIs & Integrations\
**Tags:** php, professional, contacts\
**Created:** [December 11, 2022, 12:27am UTC](https://community.hubspot.com/t/api-cant-add-contact-associations-on-php/70968 "2022-12-11T00:27:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Micole](https://avatars.discourse-cdn.com/v4/letter/m/c5a1d2/32.png) [@Micole](https://community.hubspot.com/u/Micole)\
**Post date:** [December 11, 2022, 12:27am UTC](https://community.hubspot.com/t/api-cant-add-contact-associations-on-php/70968/1 "2022-12-11T00:27:26Z")

</div>

I am trying to associate contacts with companies by following current documentation:

> **[Accounts Dashboard | HubSpot](https://app.hubspot.com/myaccounts?next=developerdocs&redirect=%2Fapi-reference%2Fcrm-contacts-v3%2Fguide)**

However for my case PHP Library doesnt really have the “HubSpot\Client\Crm\Contacts\Model\AssociationSpec” so I cant follow that code, so I decided to do it by CURL.  
I made this curl which seems correct to me:

```lia-code-sample
$url = 'https://api.hubapi.com/crm/v4/objects/contacts/1/associations/Company/2';

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
 'authorization: Bearer YOUR_ACCESS_TOKEN',
 'content-type: application/json'
));
curl_setopt($ch, CURLOPT_POSTFIELDS, '[
 {
 "associationCategory": "USER_DEFINED",
 "associationTypeId": 0
 },
 {},
 {},
 {}
]');

$response = curl_exec($ch);
curl_close($ch);

```

After I send this curl I receive the error bellow:

`{"status":"error","message":"Invalid input JSON on line 6, column 4. Some required fields were not set: [associationCategory, associationTypeId]","correlationId":"f940079b-7f65-4794-a13d-35ac905cc349","category":"VALIDATION_ERROR"}`

Dont quite follow, I am inserting associationCategory and associationTypeId.  
Do you guys can give some help?

---

<div class="post-metadata">

**Author:** ![Micole](https://avatars.discourse-cdn.com/v4/letter/m/c5a1d2/32.png) [@Micole](https://community.hubspot.com/u/Micole)\
**Post date:** [December 11, 2022, 12:39am UTC](https://community.hubspot.com/t/api-cant-add-contact-associations-on-php/70968/2 "2022-12-11T00:39:59Z")

</div>

A found the fix in the changelog of hubspot-api-php, they just uploaded a fix few days ago:

> <https://github.com/HubSpot/hubspot-api-php/blob/master/CHANGELOG.md>

It gets fixed from 9.0.1 version

---

<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:** [December 13, 2022, 10:21pm UTC](https://community.hubspot.com/t/api-cant-add-contact-associations-on-php/70968/3 "2022-12-13T22:21:25Z")

</div>

Thanks for the update @Micole 🙌
