API - Create Engagements - Error Message


#1

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


#2

Is my JSON file structure incorrect?


#3

Hi @aliknox,

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

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

#4

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