Hi all
Newbie here.
I’m writing an app to import GoldMine history into Hubspot as completed tasks.
I’ve managed to, as a test create a company, so I know I’m not far away but when I try and add an egagement task I just keep getting Bad Request. Quite frankly this is f’ing useless information but it is what it is.
Here is an example json string I’m building from a SQL query to the GoldMine database:
{
“engagement”: {
“active”: true,
“ownerId”: 1,
“type”: “TASK”,
“timestamp”: 130181149200000000
},
“associations”: {
“contactIds”: [
1
],
“companyIds”: [],
“dealIds”: [],
“ownerIds”: []
},
“metadata”: {
“body”: “\r\n\r\n \r\n\r\n\r\n\r\n\u0000”,
“subject”: " (oc:Aurangzeb Khan)",
“status”: “COMPLETED”,
“forObjectType”: “CONTACT”
}
}
Here is my code:
Dim newTask As New newTask
Dim onDateTime As DateTime = contHist(“ondatetime”)
Dim newEngagement As New Engagement
With newEngagement
.active = “true”
.type = “TASK”
.timestamp = contHist(“ONDATETIME”).ToFileTime
.ownerId = 1
End With
Dim newAssociations As New Associations
With newAssociations
.contactIds = {1}
.companyIds = {}
.dealIds = {}
.ownerIds = {}
End With
Dim newMetaData As New Metadata
With newMetaData
.body = contHist(“ConvertedNotes”)
.subject = contHist(“REF”)
.status = “COMPLETED”
.forObjectType = “CONTACT”
End With
With newTask
.engagement = newEngagement
.associations = newAssociations
.metadata = newMetaData
End With
Dim jSonNewTask As String = JsonConvert.SerializeObject(newTask, Formatting.Indented)
Dim contactContent As New StringContent(jSonNewTask, Encoding.UTF8, “application/json”)
Dim url As String = “https://api.hubapi.com/engagements/v1/engagements?hapikey=myapikey”
Dim client As HttpClient = New HttpClient
client.BaseAddress = New Uri(url)
client.DefaultRequestHeaders.Accept.Add(New MediaTypeWithQualityHeaderValue(“application/json”))
client.MaxResponseContentBufferSize = 2147483647
client.Timeout = TimeSpan.FromMinutes(5)
Dim response As HttpResponseMessage = client.PostAsync(url, contactContent).GetAwaiter.GetResult
If response.IsSuccessStatusCode Then
Dim a As String = response.ReasonPhrase
End If