# API - Create Engagements - Error Message

**URL:** <https://community.hubspot.com/t/api-create-engagements-error-message/11899>\
**Category:** APIs & Integrations\
**Tags:** events\
**Created:** [February 1, 2018, 7:54pm UTC](https://community.hubspot.com/t/api-create-engagements-error-message/11899 "2018-02-01T19:54:13Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [February 1, 2018, 7:54pm UTC](https://community.hubspot.com/t/api-create-engagements-error-message/11899/1 "2018-02-01T19:54:13Z")

</div>

Hi this is the first time I have done this. I’ve created a test account and trying to add an engagement to an existing company. And I get the following error.

Status code: 400  
Response: {“status”:“error”,“message”:“Invalid input JSON on line 1, column 15: Can not deserialize instance of com.hubspot.engagements.base.detail.views.EngagementView out of START\_ARRAY token”,“correlationId”:“43b0088a-9991-4980-abe0-3e39750dbaab”,“requestId”:“db0d3584988ae0b441a650cae2d5e38c”}

Below is the JSON I’m passing.

{“engagement”:[{“property”:“active”,“value”:“True”},{“property”:“ownerId”,“value”:“31308819”},{“property”:“type”,“value”:“NOTE”},{“property”:“timestamp”,“value”:1517514219}],“associations”:[{“property”:“contactIds”,“value”:“2”},{“property”:“companyIds”,“value”:“686724768”}],“metadata”:[{“property”:“body”,“value”:“Import Record Test”}]}

Any help would be appreciated.

Thanks,

Ali

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [February 2, 2018, 10:42am UTC](https://community.hubspot.com/t/api-create-engagements-error-message/11899/2 "2018-02-02T10:42:41Z")

</div>

![](https://d2qpr2jzcazej7.cloudfront.net/original/3X/a/6/a6164523944beeda543ceb0bd4abbf531878711a.png) aliknox:

> Invalid input JSON on line 1, column 15: Can not deserialize instance

Is my JSON file structure incorrect?

---

<div class="post-metadata">

**Author:** ![Derek\_Gervais](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/derek_gervais/32/17429_2.png) [@Derek\_Gervais](https://community.hubspot.com/u/Derek_Gervais)\
**Post date:** [February 6, 2018, 6:06pm UTC](https://community.hubspot.com/t/api-create-engagements-error-message/11899/3 "2018-02-06T18:06:06Z")

</div>

Hi [@aliknox](https://community.hubspot.com/u/aliknox),

You’re correct; the `engagement`, `associations`, and `metadata` fields aren’t arrays, they’re objects. The request body should look like this:

```auto
{
 "engagement": {
 "active": true,
 "ownerId": 1,
 "type": "NOTE",
 "timestamp": 1409172644778
 },
 "associations": {
 "contactIds": [
 2
 ],
 "companyIds": [],
 "dealIds": [],
 "ownerIds": []
 },
 "attachments": [
 {
 "id": 4241968539
 }
 ],
 "metadata": {
 "body": "note body"
 }
 }

```

![](https://d2qpr2jzcazej7.cloudfront.net/original/3X/c/8/c85b9e156eb55700ffb18fc15982cc795593787e.png) [developers.hubspot.com](https://developers.hubspot.com/docs/methods/engagements/create_engagement)

### [Create an Engagement | Engagements API](https://developers.hubspot.com/docs/methods/engagements/create_engagement)

POST /engagements/v1/engagements - Create an engagement via the HubSpot API.

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [February 8, 2018, 1:45pm UTC](https://community.hubspot.com/t/api-create-engagements-error-message/11899/4 "2018-02-08T13:45:35Z")

</div>

Thanks, I have resolved this, it was an array conversion problem.

---

<div class="post-metadata">

**Author:** ![jaywhy](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaywhy/32/9140_2.png) [@jaywhy](https://community.hubspot.com/u/jaywhy)\
**Post date:** [April 7, 2020, 4:04pm UTC](https://community.hubspot.com/t/api-create-engagements-error-message/11899/5 "2020-04-07T16:04:12Z")

</div>

Please could you explain how you resolved as I am having the same issue?

---

<div class="post-metadata">

**Author:** ![jaywhy](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaywhy/32/9140_2.png) [@jaywhy](https://community.hubspot.com/u/jaywhy)\
**Post date:** [January 11, 2021, 9:35am UTC](https://community.hubspot.com/t/api-create-engagements-error-message/11899/6 "2021-01-11T09:35:24Z")

</div>

I found my own solution to this issue and will post it here as I have received a couple of upvotes to my initial question. Hopefully it will help someone else.

```lia-code-sample
var createjsonVar = [];

createjsonVar.push({
 engagement: {
 active: true,
 type: "TASK",
 timestamp: new Date().getTime(,
 ownerId: ownerId
 },
 associations: {
 contactIds: [contactID]
 },
 metadata: {
 subject: 'follow up',
 body: taskBody,
 status: 'NOT_STARTED'
 }
});

var createjson = JSON.stringify(createjsonVar);
var body = createjson.substr(1, createjson.length - 2);

```

By taking a substring of the output you are removing the initial opening square bracket which causes the error.

I know it’s probably not the best solution but it works!

---

<div class="post-metadata">

**Author:** ![dennisedson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dennisedson/32/28044_2.png) [@dennisedson](https://community.hubspot.com/u/dennisedson)\
**Post date:** [January 11, 2021, 6:54pm UTC](https://community.hubspot.com/t/api-create-engagements-error-message/11899/7 "2021-01-11T18:54:15Z")

</div>

Thanks for posting your solution, @jaywhy !

---

<div class="post-metadata">

**Author:** ![mcraciun](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/mcraciun/32/48852_2.png) [@mcraciun](https://community.hubspot.com/u/mcraciun)\
**Post date:** [April 20, 2021, 7:06pm UTC](https://community.hubspot.com/t/api-create-engagements-error-message/11899/8 "2021-04-20T19:06:50Z")

</div>

I ran into a similar issue and it was caused by having ownerId in an array, which it shouldn’t be in
