APIs & Integrations

ricky23
Contributor

Not able to create a note-Engagement

SOLVE

I am try to create a note for a deal via the Hubspot Engagements API but I get an Error

FetchError: invalid json response body at https://api.hubapi.com/engagements/v1/engagements?hapikey=demo reason: Unexpected end of JSON input

 

Here is the code that I have written-

 

var fetch = require("node-fetch");

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

  url_deal='https://api.hubapi.com/engagements/v1/engagements?hapikey=demo';
  fetch(url_deal, {
    method: 'put',
    headers: {
      'Accept': 'application/json, text/plain, */*',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify(form)
  }).then(res=>res.json())
    .then(res => context.log(res));

Any help on this matter would be greatly appreciated!

0 Upvotes
1 Accepted solution
IsaacTakushi
Solution
HubSpot Employee
HubSpot Employee

Not able to create a note-Engagement

SOLVE

Hey, @ricky23.

 

It looks like you found the issue in this post: You were using the PUT method when this endpoint only accepts POST.

Isaac Takushi

Associate Certification Manager

View solution in original post

0 Upvotes
1 Reply 1
IsaacTakushi
Solution
HubSpot Employee
HubSpot Employee

Not able to create a note-Engagement

SOLVE

Hey, @ricky23.

 

It looks like you found the issue in this post: You were using the PUT method when this endpoint only accepts POST.

Isaac Takushi

Associate Certification Manager
0 Upvotes