# Handle hubSpot API response

**URL:** <https://community.n8n.io/t/handle-hubspot-api-response/48263>\
**Category:** Questions\
**Tags:** core, http-request, code\
**Created:** [11 Junio, 2024 07:21 UTC](https://community.n8n.io/t/handle-hubspot-api-response/48263 "2024-06-11T07:21:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gouravdev](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/gouravdev/32/14036_2.png) [@Gouravdev](https://community.n8n.io/u/Gouravdev)\
**Post date:** [11 Junio, 2024 07:21 UTC](https://community.n8n.io/t/handle-hubspot-api-response/48263/1 "2024-06-11T07:21:36Z")

</div>

## 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

```auto
[
  {
    "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": "a@gmail.com",
        "type": "company_to_contact"
      },
      {
        "id": "22837682956",
        "email": "b@gmail.com",
        "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

---

<div class="post-metadata">

**Author:** ![barn4k](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/barn4k/32/8170_2.png) [@barn4k](https://community.n8n.io/u/barn4k)\
**Post date:** [11 Junio, 2024 20:26 UTC](https://community.n8n.io/t/handle-hubspot-api-response/48263/2 "2024-06-11T20:26:56Z")

</div>

hello @Gouravdev

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

---

<div class="post-metadata">

**Author:** ![Gouravdev](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/gouravdev/32/14036_2.png) [@Gouravdev](https://community.n8n.io/u/Gouravdev)\
**Post date:** [12 Junio, 2024 12:08 UTC](https://community.n8n.io/t/handle-hubspot-api-response/48263/3 "2024-06-12T12:08:24Z")

</div>

I have fixed it.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/system/32/36532_2.png) [@system](https://community.n8n.io/u/system)\
**Post date:** [19 Junio, 2024 12:08 UTC](https://community.n8n.io/t/handle-hubspot-api-response/48263/4 "2024-06-19T12:08:53Z")

</div>

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