HTTP Request Cannot deserialize value of type

I’m making an HTTP request to send a form to the hubspot, I need to send two arrays in the body, following example:

“fields”: [
{
“objectTypeId”: “0-1”,
“name”: “email”,
“value”: “[email protected]
},
{
“objectTypeId”: “0-1”,
“name”: “firstname”,
“value”: “Jeff”
}
],
“context”: {
“hutk”: “:hutk”, // include this parameter and set it to the hubspotutk cookie value to enable cookie tracking on your submission
“pageUri”: “www.example.com/page”,
“pageName”: “Example page”
},

I tried to do it using set, but I get the following message when I try to make the request: Invalid input JSON on line 1, column 156: Cannot deserialize value of type com.hubspot.formsubmission.core.models.PublicApiFormSubmissionContext from Array value (token JsonToken.START_ARRAY)

I believe I’m sending the parameter the wrong way, and I apologize for my ignorance, can anyone help me find the solution?

Below is the flow I’m using

Hey @lucascosta,

Do you have an example of what data Hubspot is expecting to recieve? I suspect the issue is with the data that is being sent but if you have an example that works with CURL we should be able to take that and make it work with n8n.

I have also modified your post as I noticed there was an API key in it so I have removed it for you.

@Jon follows the example of hubspot delivery, it has the request that the hubspot receives.

Thanks for removing the API key, I just forgot.

Hey @lucascosta,

Looking at the hubspot docs it looks like the wrong data is being sent.

 "fields": [
    {
      "objectTypeId": "0-1",
      "name": "email",
      "value": "[email protected]"
    },
    {
      "objectTypeId": "0-1",
      "name": "firstname",
      "value": "Jeff"
    }
  ],

They expect the fields to contain those 3 values so your request may need…

 "fields": [
    {
      "objectTypeId": "0-1",
      "name": "firstname",
      "value": "lucas"
    },
    {
      "objectTypeId": "0-1",
      "name": "email",
      "value": "[email protected]"
    },
    {
      "objectTypeId": "0-1",
      "name": "pageUrl",
      "value": "newtrend.digital"
    }
  ],

I am not sure if objectTypeId changes but I suspect it might depending on the data being sent. As a quick concept I have fired off a test using your key and it appears to have worked so I think this could be the bit that was missing and should help you finish up with this one :slight_smile:

@Jon the lead actually entered the platform, but still without the url parameter, inside the body, I need to send two arrays, which would be the fields and context, as in the example below

"fields": [
    {
      "objectTypeId": "0-1",
      "name": "email",
      "value": "[email protected]"
    },
    {
	  "objectTypeId": "0-1",
      "name": "firstname",
      "value": "Jeff"
    }
  ],
  "context": {
    "hutk": ":hutk", // include this parameter and set it to the hubspotutk cookie value to enable cookie tracking on your submission
    "pageUri": "www.example.com/page",
    "pageName": "Example page"
  },

Segue o print do lead que foi criado.

@Jon ended up not adding the concussion.

In the flow I sent when opening the ticket, I put two sets, one with fields and one with context and then inside the body I specified the values ​​of these nodes, but I get the error Invalid input JSON on line 1, column 156: Cannot deserialize value of type com.hubspot.formsubmission.core.models.PublicApiFormSubmissionContextfrom Array value (JsonToken.START_ARRAY token)

Hey @lucascosta,

The deserlialize error is coming back from Hubspot it was saying the data wasn’t being sent correctly. One thing I did notice with the original flow was it was trying to send the data twice as there are 2 inputs which may not be ideal. I ended up removing context as Hubspot wasn’t happy with the htuk value (I think) but for a more complete example that should do both check out the workflow below.

@Jon Perform the test, it worked, thanks for the support, I could understand the logic you used. Thank you very much.

1 Like