Importing Contacts into HubSpot

I have a set of Contacts in a Xojo database that I wish to import into HubSpot using Xojo. From the documentation it seems I need to create a JSONItem then send it to HubSpot using an HTTPSecureSocket. From a previous forum post ( I can see that @John Joyce has done a similar action from WordPress.
I have tried sending the JSON contact to their public demo and to my account using my hapi-key, but the new contact never appears and I am not getting any results in return.

I have created a new HTTPSecureSocket, Dictionary and JSONItem. I then populate the dictionary, connect to the API, convert the dictionary to JSON, then send the JSON to the HTTPSecureSocket. Is there something obvious I’m doing wrong?

[code]Dim tempHTTPSecureSocket As New HTTPSecureSocket
Dim tempDictionary As New Dictionary
Dim Row As New JSONItem

tempHTTPSecureSocket.Secure = True

while not rs.EOF
tempDictionary = New Dictionary
tempDictionary.Value(“firstname”) = rs.Field(“firstname”).StringValue
tempDictionary.Value(“lastname”) = rs.Field(“lastname”).StringValue
tempDictionary.Value(“emailaddress”) = rs.Field(“emailaddress”).StringValue
tempDictionary.Value(“phonenumber”) = rs.Field(“phonenumber”).StringValue
tempDictionary.Value(“jobtitle”) = rs.Field(“jobtitle”).StringValue
tempDictionary.Value(“organisationname”) = rs.Field(“organisationname”).StringValue


Row = New JSONItem
Row = tempDictionary

I have also tried sending the Dictionary as a form (without success) with:


I have also tried using CURLSMBS (using CURLSMBS.OptionUpload), but cannot seem to add a Contact this way either.

So what actually happens? Does the API return an error? Do you get a bad HTTP response code? Nevermind, I found it, but it was hidden in your post :stuck_out_tongue:

Are you sure you’re not getting any kind of response? No HTTP response code?

Without knowing what’s going wrong, have you tried using a Xojo.Net.HTTPSocket instead?

Also, I don’t see any kind of connection throttling, their server might not like that.

Thanks Tim,
Yes I tried Xojo.Net.HTTPSocket after I submitted this forum post but got no results.

It seems that HubSpot is pick on how the JSON is formatted and doesn’t like the Xojo JSONItem.ToString format. I wrote their sample JSON to a file and submitted it via Xojo and it imported the contact. I used:

tempHTTPSecureSocket.SetRequestContent("My JSON string goes here…", "application/json; charset=utf-8") hubSpotResults = tempHTTPSecureSocket.Post("", 30)
I am now formatting my JSON exactly as their format and will see how it goes.

I was reading the docs and I think you can’t use:

tempHTTPSecureSocket.Post(Row.ToString) or tempHTTPSecureSocket.SetFormData(tempDictionary)
to send the data.

Edit: I see that now you are using .SetRequestContent