APIs & Integrations

ricky23
Colaborador

Not able to create a note for a deal-Engagement

resolver

I get this error message when I try to create a note for a deal in Hubspot-

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

 

This is the code that I have written,

 

var form = {
    "engagement": {
        "active": true,
         "type": "NOTE",
        
    },
    "associations": {
        "companyIds": [ ],
        "dealIds": [123],
        "ownerIds": [ ]
    },
    "attachments": [
        {
            
        }
    ],
    "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 Me gusta
1 Soluciones aceptada
ricky23
Solución
Colaborador

Not able to create a note for a deal-Engagement

resolver

I found the Issue that I was having. I was using "put" Instead of "POST" for the fetch call. 

 

//Attempt to create a note for a deal in Hubspot

var fetch = require("node-fetch");
var urlBody="https://www.google.com";
var form = {
    "engagement": {
        "active": true,
        "type": "NOTE",
        
    },
    "associations": {
      "dealIds": [123]
        
    },
    "metadata": {
        "body": urlBody
    }
}

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

Ver la solución en mensaje original publicado

3 Respuestas 3
ricky23
Colaborador

Not able to create a note for a deal-Engagement

resolver

Waiting for a response here ...

0 Me gusta
ricky23
Solución
Colaborador

Not able to create a note for a deal-Engagement

resolver

I found the Issue that I was having. I was using "put" Instead of "POST" for the fetch call. 

 

//Attempt to create a note for a deal in Hubspot

var fetch = require("node-fetch");
var urlBody="https://www.google.com";
var form = {
    "engagement": {
        "active": true,
        "type": "NOTE",
        
    },
    "associations": {
      "dealIds": [123]
        
    },
    "metadata": {
        "body": urlBody
    }
}

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

IsaacTakushi
HubSpot Employee
HubSpot Employee

Not able to create a note for a deal-Engagement

resolver

Hey, @ricky23.

 

Apologies that this post fell through the cracks. My team strives to respond to posts within 48 hours.

 

I'm glad you found the solution!

Isaac Takushi

Associate Certification Manager
0 Me gusta