APIs & Integrations

keiron77
Member

Create an Engagement API error

I have been working on the api to Create an Engagement but I am getting this response:

({“status”:“error”,“message”:“internal error”,“correlationId”:“75ad1f1e-d95d-4019-9bb7-839c096ba743”,“requestId”:“1f2f10e7420836cca81f954ecea54963”})

Does anyone know why? I am sending this data:

{“engagement”:{“active”:true,“type”:“EMAIL”},“metadata”:{“from”:{“email”:“support@domain.co.uk”,“firstName”:“First”,“lastName”:“Last”},“to”:{“email”:“user@domain.co.uk”},“cc”:"",“bcc”:"",“subject”:“This is the subject of the email”,“html”:“This is the body of the email”,“text”:“This is the body of the email”}}

To https://api.hubapi.com/engagements/v1/engagements?hapikey=xxxxxxxx (where xxxx is my api key) using cURL in php

0 Upvotes
3 Replies 3
keiron77
Member

Create an Engagement API error

I think I have it working and now the post is responding with the following rather than an error:

{“engagement”:{“id”:xxxxxx,“portalId”:xxxxxx,“active”:true,“createdAt”:1491317239185,“lastUpdated”:1491317239185,“type”:“EMAIL”,“timestamp”:1491317239185},“metadata”:{“from”:{“email”:“email@xxxxxx.co.uk”,“firstName”:“First”,“lastName”:“Last”},“to”:[{“email”:“contact@xxxx.co.uk”}],“cc”:[],“bcc”:[],“subject”:“This is the subject of the email”,“html”:“This is the body of the email”,“text”:“This is the body of the email”}}

But I don’t see it appearing in the dashboard against the “to” contact. Why is that?

I am assuming ‘engagements’ should be found in the ‘activities’ timeline.

0 Upvotes
3PETE
HubSpot Employee
HubSpot Employee

Create an Engagement API error

@keiron77 You still need to associate the contact to the user now.

0 Upvotes
3PETE
HubSpot Employee
HubSpot Employee

Create an Engagement API error

@keiron77

I would make sure your JSON is formatted correctly. It looks like your “to” is an object and not an array for starters. That might be part of the problem.

"metadata": {
    "from": {
      "email": "email@domain.com",
      "firstName": "First",
      "lastName": "Last"
    },
    "to": [
      {
        "email": "contact name <test@test.com>"
      }
    ],
    "cc": [],
    "bcc": [],
    "subject": "This is the subject of the email",
    "html": "<div>This is the body of the email</div><div><br></div><div>-Me</div>",
    "text": "This is the body of the email\n\n-Me"
}
0 Upvotes