API created contacts and Associations not showing

I recently started programming an integration between our billing software (WHMCS) and Hubspot, when a new client is created in our billing software a hook script triggers which does three things, it first creates a company via the Api and stores the comanyid, this is successful and displays correctly in the frontend.
It then creates a contact with all the client information and stores the vid number. This works, however, the hubspot interface doesn’t always show the contact, it seems like it fails but if I try to create the same user again I get an error and linked to the contact in question, why this contact isn’t displayed in the frontend interface I dont know.
The third thing that the script does is create an association using the companyId and vid to link the two. This also seems successful based on the curl response but again the association doesn’t show in the frontend interface.
My question I suppose is: Are the frontend views cached in some way, can I invalidate that cache, are these issues I can work around in some way? Below is the code I’m using for the association, I’ve confirmed all varibles are populated correctly:

 //PUT request curl for associations 
 $assArray = array(
 'fromObjectId' => $companyID,
 'toObjectId' => $contactID,
 'category' => 'HUBSPOT_DEFINED',
 'definitionId' => '2'
 );
 $ch = curl_init($endpointAss);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
 curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($assArray));
 $response = curl_exec($ch);
 //logActivity($contactID, 0);
 //logActivity($companyID, 0);

I’m stumpped on this one as my code seems to be working just fine but the results from the frontend of the test account are inconsistent, as such I cant trust what I’m seeing in there. Any help would be greatly appreciated.

Hi @lukekelsall,

I hope all is well with you :grinning_face_with_smiling_eyes:

Do you mean that when using this endpoint: Create a new contact | Contacts API to create contact and this endpoint: Associate CRM objects to create association between company and contact object, you’re seeing that after sending the request, your HubSpot portal isn’t showing the contact or association instantly?

When testing it on my end in my own portal, I create a contact using this endpoint Create a new contact | Contacts API with the following POST body:

{
 "properties": [
 {
 "property": "email",
 "value": "testingapis@hubspot.com"
 },
 {
 "property": "firstname",
 "value": "Adrian"
 },
 {
 "property": "lastname",
 "value": "Mott"
 },
 {
 "property": "website",
 "value": "http://hubspot.com"
 },
 {
 "property": "company",
 "value": "HubSpot"
 },
 {
 "property": "phone",
 "value": "555-122-2323"
 },
 {
 "property": "address",
 "value": "25 First Street"
 },
 {
 "property": "city",
 "value": "Cambridge"
 },
 {
 "property": "state",
 "value": "MA"
 },
 {
 "property": "zip",
 "value": "02139"
 }
 ]
}

and I was able to see the contact instantly on my contact dashboard after refreshing the page once.

Next, I use this endpoint: Associate CRM objects with the following PUT body:

{
 "fromObjectId": 868488943,
 "toObjectId": 98901,
 "category": "HUBSPOT_DEFINED",
 "definitionId": 2
}

and after refreshing the contact record page, I was able to see the association.

In this case, do you mind sharing with me the portal where you’re creating the contact and making the association? So that I can further test things out on my end.

Hi Wendy,

Thats exactly right, the contacts api endpoint first, with a success response and then the associations endpoint with an empty response, which I believe is a success. But this isn’t reflected in the interface.

I’m currently using a test dev account with the following domain name: nubluetest-dev-6541738.com

I notice this morning that my contacts from tests yesterday are showing correctly, but the associations still aren’t showing currently.

Really appreciate any assistance you can priovide.

Hi @lukekelsall,

Thanks for providing the information.

On my end, I ran the same test that I did on my own portal, in your portal 6541738. First, I I create a contact using this endpoint Create a new contact | Contacts API with the same POST body and I was able to see contact Adrian Mott created almost instantly.

Next, I use this endpoint: Associate CRM objects with the following PUT body:

{
 "fromObjectId": 2481995823,
 "toObjectId": 201,
 "category": "HUBSPOT_DEFINED",
 "definitionId": 2
}

and I was able to see that contact Adrian Mott was associated with company Nublue Ltd NEW TEST almost instantly too.

To ensure that our test is consistent, would you mind running this endpoint on API client such as Postman?

Hi Wendy,

Thanks for the test, I have re-run my own tests on this end and everything is now working, same code no changes, perhaps it was a caching issue? Not entirely sure, thanks for looking into this for me regardless.

Regards