Handle hubSpot API response

Describe the problem/error/question

Hi Team,

I hope you are doing well.

I have a use case where I need to reevaluate and restructure the response I get from the HubSpot API. Over the past few days, I have tried different approaches but haven’t been successful.

Currently, from the output of the HTTP node getHubSpotCompanies, we are getting associated contact IDs and deal IDs.

Here are the steps I am looking to implement:

  1. Merge duplicate records (IDs) into a single ID for associations.deals and associations.contacts from the listAssociatedContacts node.
  2. Use other HTTP (HubSpot API) nodes to retrieve the email ID of the contact (getAssociatedContacts) and the deal name (getAssociatedDeals).
  3. Then, add the retrieved information into the respective IDs.

Could you please provide guidance or suggestions on how to achieve this?

Thank you!

My expected response

[
  {
    "id": "16682150262",
    "properties": {
      "annualrevenue": "1000000",
      "createdate": "2023-07-24T08:17:56.265Z",
      "domain": "companya.com",
      "hs_lastmodifieddate": "2024-05-22T10:37:25.816Z",
      "hs_object_id": "16682150262",
      "hubspot_owner_id": "479737671",
      "industry": "MARKETING_AND_ADVERTISING",
      "name": "Company A",
      "numberofemployees": "50",
      "phone": "+1 925-570-6699"
    },
    "createdAt": "2023-07-24T08:17:56.265Z",
    "updatedAt": "2024-05-22T10:37:25.816Z",
    "archived": false,
    "associations": {},
    "associations.deals": [
      {
        "id": "14294059103",
        "dealname": "Deal A",
        "type": "company_to_deal"
      }
    ],
    "associations.contacts": [
      {
        "id": "251",
        "email": "[email protected]",
        "type": "company_to_contact"
      },
      {
        "id": "22837682956",
        "email": "[email protected]",
        "type": "company_to_contact_unlabeled"
      }
    ]
  }
]

What is the error message (if any)?

NA

Please share your workflow

Share the output returned by the last node

Information on your n8n setup

  • n8n version: 0.234.1
  • Database (default: SQLite): postgresql
  • n8n EXECUTIONS_PROCESS setting (default: own, main): Default
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: MAC

hello @Gouravdev

Can you provide some samples for the node getHubSpotCompanies? Like 3-5 items

1 Like

I have fixed it.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.