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 (https://forum.xojo.com/40540-getting-web-pages) 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
tempHTTPSecureSocket.Post(“https://api.hubapi.com/contacts/v1/contact/?hapikey=demo”)
Row = New JSONItem
Row = tempDictionary
tempHTTPSecureSocket.Post(Row.ToString)
rs.MoveNext
wend
[/code]
I have also tried sending the Dictionary as a form (without success) with:
tempHTTPSecureSocket.SetFormData(tempDictionary)
I have also tried using CURLSMBS (using CURLSMBS.OptionUpload), but cannot seem to add a Contact this way either.