APIs & Integrations

SN1
Member

Create contact is updating vid 101?

SOLVE

Hi,

 

I'm currently having a very strange issue that I'm hoping someone has seen before.  We've integrated the API to send data from a form on our website to Hubspot via the contacts/v1/contact/ method.  We're finding that on a regular basis (although not always) we get an error saying the contact already exists, when we know categorically that it does not.  When we check the list via the API using contacts/v1/lists/all/contacts/all/ we can see that there is a contact with a vid of 101 and the contact we're trying to add overwrites the firstname, lastname, etc. fields, with their email address being set to the primary email.  What's strange is that every time we've got this error, this happens and the previous email changes to a secondary email, but doesn't get deleted.  This doesn't always happen, sometimes the contact gets created as we expect.

 

This is really strange as we're not using the create or update method and the contact definitely does not exist before we add it, so I can't see how it is matching.  I've tried several approaches, but the following code has exhibited this behaviour:

var hapikey = "api-key-here";
var client = new RestClient("https://api.hubapi.com/");
var request = new RestRequest("contacts/v1/contact/", Method.POST);
request.AddQueryParameter("hapikey", hapikey);
request.RequestFormat = DataFormat.Json;

request.AddJsonBody(new
{
properties = new[]
{
new { property = "email", value = "test12345@mailinator.com"},
new { property = "firstname", value = "Dooug"},
new { property = "lastname", value = "Stevens2299" },
new { property = "phone", value = "+1 54564 65464"},
new { property = "message", value = "This is a test"},
new { property = "sign_up_for_updates", value ="Yes"

}
}
});

 

This is a real problem as we can't rely on HubSpot to create a new contact each time at the moment.

 

Thanks in advance!

0 Upvotes
1 Accepted solution
SN1
Solution
Member

Create contact is updating vid 101?

SOLVE

I'll try and remember as it was a while back (so details are a bit hazy) but we did find out what was happening.  The set up of the Hubspot account meant that we had some Javascript from Hubspot added to our page which was supposed to help with tracking, but it was also intercepting form posts and sending this back to Hubspot as a new contact.  So we had the API add a contact and then the JS try and add one as well (or vice versa depending on which one got there first) which was causing contacts to be updated with data from the API to be overwritten by data from the form or being flagged as existing already. 

 

We were using the API as the form had non standard elements that we were dealing with in our BE code.  When the JS was sending the form data back, it was guessing what fields on the form contained what data when matching up with the contact fields in Hubspot and guessing wrong, which was causing our data to get messed up.  Think in the end we had to enable non-hubspot forms in our settings for it to work  (think it was this link https://knowledge.hubspot.com/forms/use-non-hubspot-forms) and then it started to behave correctly.

 

Hope this helps!

View solution in original post

0 Upvotes
5 Replies 5
dennisedson
HubSpot Product Team
HubSpot Product Team

Create contact is updating vid 101?

SOLVE

@SN1 

Apologies for delayed response.  That is a weird issue 🤔

Is there a reason you use the V1 instead of the V3 api?

Not saying that the v1 should be exhibiting this behavior, but was wondering if you could give that v3 endpoint a go and see if it persists

0 Upvotes
CMetaliya
Member

Create contact is updating vid 101?

SOLVE

This same issue is happening with me currently with v3 endpoint as well. I've posted my issue, if you could help me out, please do on my post here. https://community.hubspot.com/t5/APIs-Integrations/While-Creating-Contact-It-Gives-Error-That-Contac...

0 Upvotes
SN1
Solution
Member

Create contact is updating vid 101?

SOLVE

I'll try and remember as it was a while back (so details are a bit hazy) but we did find out what was happening.  The set up of the Hubspot account meant that we had some Javascript from Hubspot added to our page which was supposed to help with tracking, but it was also intercepting form posts and sending this back to Hubspot as a new contact.  So we had the API add a contact and then the JS try and add one as well (or vice versa depending on which one got there first) which was causing contacts to be updated with data from the API to be overwritten by data from the form or being flagged as existing already. 

 

We were using the API as the form had non standard elements that we were dealing with in our BE code.  When the JS was sending the form data back, it was guessing what fields on the form contained what data when matching up with the contact fields in Hubspot and guessing wrong, which was causing our data to get messed up.  Think in the end we had to enable non-hubspot forms in our settings for it to work  (think it was this link https://knowledge.hubspot.com/forms/use-non-hubspot-forms) and then it started to behave correctly.

 

Hope this helps!

0 Upvotes
CMetaliya
Member

Create contact is updating vid 101?

SOLVE

Thank you very much buddy. It resolved my issue as well. Never knew why that script was there at first place.

SN1
Member

Create contact is updating vid 101?

SOLVE
No problem, glad it helped!