I am having trouble with POST request with HTTP for HubSpot custom Objects

Hello, I am new to this community and quite new to n8n. This is my first API project (connecting a database to Hubspot). Because I have created custom objects, I must use the HTTP Request node. The process begins with a Cron, then a HTTP Request to get the information (quite large), followed by a Function node to group entries (contact and contact data), then an Item List node (mainly for testing to limit the amount) and then the HTTP Request to post into Hubspot. At first I was receiving the error “ERROR: UNKNOWN ERROR - check the detailed error for more information…validation error…The request body may not be null.” So with the Body Parameters I tested one entry with all the properties. I got it to go through. So I attempted to put in a Body Parameter as I’d seen done here in the community: Insert Name, Add expression to value, click "Current Node, click "Input Data, but I did not have “options.” Instead it states [Data to large]. I followed another example by going to RAW parameters, click add expression next to Body parameter -. current node - input - JSON - options but an error appeared there as well. (I cannot recreate it at the moment to get the specific error). Let me know if any other information would be helpful. Thank you in advance for your assistance.

Here is the workflow:

The output for the last node is similar to a contact and their contact information (this is for a group but the same; so their name, address, etc).

Currently using the n8n desktop

Hey @TDean, welcome to the community :tada:

So just to make sure I understand the problem, your workflow is working fine up until the Item Lists1 node? Could you share the output form this node (you can of course redact the data itself, I am just interested in the structure)?

I haven’t used custom objects in Hubspot yet but I’ll give this a go once I have a bit of time :slight_smile:

Edit: After reading some of Hubspots documentation, could you also share the output of the GET https://api.hubapi.com/crm/v3/schemas API request with me? Just to make sure I understand the schema of your custom objects?

In n8n, you could query the schema using the below example workflow (you can simply copy and paste the JSON code into your n8n canvas):

Example Workflow

Hey @MutedJam, thank you!

The Item List seems to work as well; it the last HTTP node that gives an error. The output from the Item List looks like the following:

[
{
"troop_name": "",
"troop_id": "",
"charter_status": "",
"active": "",
"deleted": "",
"city": "",
"state": "",
"zipcode": "",
"region_id": "",
"region_title": "",
"area_id": "",
"area_title": "",
"pre_charter_approved_at": "",
"charter_date": "",
"troop_expiration": "",
"denomination_id": "",
"denomination_title": "",
"updated_at": ""
}]

The output of the GET request is:

[
{
"troop_id": {
"troop_name": "",
"troop_id": "",
"charter_status": "",
"active": "",
"deleted": "",
"city": "",
"state": "",
"zipcode": "",
"region_id": "",
"region_title": "",
"area_id": "",
"area_title": "",
"pre_charter_approved_at": "",
"charter_date": "",
"troop_expiration": "",
"denomination_id": "",
"denomination_title": "",
"updated_at": ""
}]

Before the function, the GET request saw only 1 item, after it nicely separates them into 377 new incoming items (if that helps the small differences above). Is the Item List output not sufficient enough for the POST request?

Thank you again.

Hey @TDean, many thanks for confirming!

I have created a new custom object schema in my Hubspot account as described in their documentation. This was the exact HTTP Request I have used:

Custom objects | Create a new schema

Afterwards I could create new custom objects using the object type ID value of the newly created object schema. This is based on the example output you have provided, but only uses a single field of the custom object for simplicity:

Custom objects | Create

From comparing this to your HTTP Request it seems you might be using the wrong URL here (mine looks like https://api.hubapi.com/crm/v3/objects/2-105213732 whereas yours looked like https://api.hubapi.com/crm/v3/objects/troop - I suspect Hubspot requires the numeric object type ID rather than the name).

The body parameters would also need to be adjusted, Hubspot seems to require a format like so:

{
  "properties": {
    "my_object_property": "{{$json["troop_id"]}}"
  }
}

I think once you update your HTTP Request node accordingly, the basic workflow idea should work :slight_smile:

1 Like

Thank you! I’m going to try this!

@MutedJam Thanks so much and apologies for the delay (too many projects at once lol) but this definitely works! My team is really excited about n8n and all the functionality.

1 Like

Nice, I am very glad to hear this works for you! Thanks so much for confirming!