APIs & Integrations

anilvithani
Membre

batch post using primary key of mysql contacts table

Hi,

 

I have created a post script in python for batch create contacts to hubspot.

 

My question is that 

 

1) is it necessary to use "email" to post contacts?

2) I used vid and filled its value using primary key value of record in mysql, creating records did not work, changing vid to email worked!

3)  how can I use primary key of records in mysql for future update of records in hubstop or it has to be done via email only?

 

 

Following block works:

for x in myresult:
  list1 = {"email":x[3], "properties": [
			{ "property":"crm_id", "value":x[0] },
			{ "property":"firstname", "value":x[1] },
			{ "property":"lastname", "value":x[2] },
			{ "property":"email", "value":x[3] },
			{ "property":"phone", "value":x[4] },
			{ "property":"jobTitle", "value":x[5] },
			{ "property":"company", "value":x[6] }
		  ] 
  }
  post_data.append(list1)

 

Following block does not work:

 

for x in myresult:
  list1 = {"vid":x[0], "properties": [
			{ "property":"firstname", "value":x[1] },
			{ "property":"lastname", "value":x[2] },
			{ "property":"email", "value":x[3] },
			{ "property":"phone", "value":x[4] },
			{ "property":"jobTitle", "value":x[5] },
			{ "property":"company", "value":x[6] }
		  ] 
  }
  post_data.append(list1)

 

 

Thank You

Krishan G

0 Votes
1 Réponse
WendyGoh
HubSpot Employee
HubSpot Employee

batch post using primary key of mysql contacts table

Hey @anilvithani,

 

When looking to create new contacts via the Create or update a group of contacts | Contacts API, you'd need to use an email address. 

 

When the vid is used, the existing contact record with that vid will be updated. It will not create/update contacts if the vid doesn't exist. 

 

In your case, your primary key records should match with the existing contacts vid ID if you'd like to update contact via the VID. 

0 Votes