<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Issue with Fetching Contacts via API (Contact Records associated to Multiple Company Records) in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/Issue-with-Fetching-Contacts-via-API-Contact-Records-associated/m-p/800384#M64447</link>
    <description>&lt;P&gt;Hi Jaycee,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Our dev responsible for this is actually the one asking haha (I'm not a dev btw, just an admin).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But basically, we wanted to have a 2-in-1 query that fetches contact data from an associated company, but failed to do so because we haven't reviewed the query string that much.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But this is all good, we actually managed to do a 2-query approach wherein we did the following:&lt;/P&gt;&lt;P&gt;1. Added this string so we can query the associated contact in a company&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;api.hubapi.com/crm/v3/objects/companies/&amp;lt;companyID&amp;gt;?associations=contacts&amp;amp;archived=false&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;2. Then whatever's the endpoint on the first one, we'll get the contact ID and get the email, first name and last name using this query string:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;api.hubapi.com/crm/v3/objects/contacts/&amp;lt;contactID&amp;gt;?archived=false&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically, the end result would be for us to post the data in our custom client reporting which will look like this (as representation only):&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RRazote8_0-1685432910840.png" style="width: 400px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/91907i29CC41FF2C8950FD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RRazote8_0-1685432910840.png" alt="RRazote8_0-1685432910840.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope that made sense haha but we'll still use the query you mentioned above in other scenarios that we will encounter. Thanks for this anyway!&lt;/P&gt;</description>
    <pubDate>Tue, 30 May 2023 07:49:19 GMT</pubDate>
    <dc:creator>RRazote8</dc:creator>
    <dc:date>2023-05-30T07:49:19Z</dc:date>
    <item>
      <title>Issue with Fetching Contacts via API (Contact Records associated to Multiple Company Records)</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Issue-with-Fetching-Contacts-via-API-Contact-Records-associated/m-p/799990#M64428</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We're having an issue currently with fetching data from HubSpot to our custom client reporting app via HubSpot's API.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just for context, we have one contact record associated to multiple company records, with the first associated company as the primary company (by default that is).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's what we're using to get the contact record data from HubSpot:&amp;nbsp;&lt;A href="https://api.hubapi.com/companies/v2/companies/" target="_blank"&gt;https://api.hubapi.com/companies/v2/companies/&lt;/A&gt;&lt;EM&gt;&amp;lt;companyID&amp;gt;&lt;/EM&gt;/contacts&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What's happening is that the contact record data for the first associated company is fetching, but for the other 3 it's not. It just posts as this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RRazote8_0-1685327373039.png" style="width: 400px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/91849i4EE3E4547B4FE528/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RRazote8_0-1685327373039.png" alt="RRazote8_0-1685327373039.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Open to any suggestion on how to fix this. Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 29 May 2023 02:30:59 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Issue-with-Fetching-Contacts-via-API-Contact-Records-associated/m-p/799990#M64428</guid>
      <dc:creator>RRazote8</dc:creator>
      <dc:date>2023-05-29T02:30:59Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Fetching Contacts via API (Contact Records associated to Multiple Company Records)</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Issue-with-Fetching-Contacts-via-API-Contact-Records-associated/m-p/800315#M64438</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/295598"&gt;@RRazote8&lt;/a&gt;&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":waving_hand:"&gt;👋&lt;/span&gt; Thanks for your question. The short answer is the endpoint you are using won't return&amp;nbsp;&lt;EM&gt;all&amp;nbsp;&lt;/EM&gt;the associated contacts for a company in a single call.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To retrieve all companies associated with a contact, you may want to use the CRM Associations API, specifically the &lt;CODE&gt;GET /crm/v3/objects/contacts/{contactId}/associations/companies&lt;/CODE&gt; endpoint. This endpoint retrieves all the companies associated with a specific contact.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have an example here using a contact and its associated companies from my test portal —&amp;nbsp;&lt;A href="https://community.hubspot.com/t5/APIs-Integrations/Get-all-associated-company-of-a-contact/m-p/751619/highlight/true#M61120" target="_blank" rel="noopener"&gt;Get all associated company of a contact&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;One thought is to iterate through each company and a separate API call for each to get the associated contacts. It's not ideal from a performance standpoint, but it's the most straightforward way that considers the limitations of the endpoint you are using.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Out of curiosity, is there a reason why you're using the Companies API endpoint — &lt;A href="https://legacydocs.hubspot.com/docs/methods/companies/get-all-companies" target="_blank" rel="noopener"&gt;Get All Companies&lt;/A&gt;, instead of the CRM Associations API endpoint? It might help the community to understand your use case better if you could provide more details.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you! — Jaycee&lt;/P&gt;</description>
      <pubDate>Mon, 29 May 2023 23:41:59 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Issue-with-Fetching-Contacts-via-API-Contact-Records-associated/m-p/800315#M64438</guid>
      <dc:creator>Jaycee_Lewis</dc:creator>
      <dc:date>2023-05-29T23:41:59Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Fetching Contacts via API (Contact Records associated to Multiple Company Records)</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Issue-with-Fetching-Contacts-via-API-Contact-Records-associated/m-p/800384#M64447</link>
      <description>&lt;P&gt;Hi Jaycee,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Our dev responsible for this is actually the one asking haha (I'm not a dev btw, just an admin).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But basically, we wanted to have a 2-in-1 query that fetches contact data from an associated company, but failed to do so because we haven't reviewed the query string that much.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But this is all good, we actually managed to do a 2-query approach wherein we did the following:&lt;/P&gt;&lt;P&gt;1. Added this string so we can query the associated contact in a company&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;api.hubapi.com/crm/v3/objects/companies/&amp;lt;companyID&amp;gt;?associations=contacts&amp;amp;archived=false&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;2. Then whatever's the endpoint on the first one, we'll get the contact ID and get the email, first name and last name using this query string:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;api.hubapi.com/crm/v3/objects/contacts/&amp;lt;contactID&amp;gt;?archived=false&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically, the end result would be for us to post the data in our custom client reporting which will look like this (as representation only):&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RRazote8_0-1685432910840.png" style="width: 400px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/91907i29CC41FF2C8950FD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RRazote8_0-1685432910840.png" alt="RRazote8_0-1685432910840.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope that made sense haha but we'll still use the query you mentioned above in other scenarios that we will encounter. Thanks for this anyway!&lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2023 07:49:19 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Issue-with-Fetching-Contacts-via-API-Contact-Records-associated/m-p/800384#M64447</guid>
      <dc:creator>RRazote8</dc:creator>
      <dc:date>2023-05-30T07:49:19Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Fetching Contacts via API (Contact Records associated to Multiple Company Records)</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Issue-with-Fetching-Contacts-via-API-Contact-Records-associated/m-p/802264#M64564</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/295598"&gt;@RRazote8&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The issue you're experiencing is likely due to the fact that the API endpoint you're using only returns the contact records that are associated with the **primary company**. To get the contact records that are associated with **all** of the companies that a contact is associated with, you'll need to use the following API endpoint:&lt;/P&gt;
&lt;P&gt;```&lt;BR /&gt;&lt;A href="https://api.hubapi.com/contacts/v2/contacts?company_ids=" target="_blank"&gt;https://api.hubapi.com/contacts/v2/contacts?company_ids=&lt;/A&gt;&amp;lt;company_id_1&amp;gt;,&amp;lt;company_id_2&amp;gt;,&amp;lt;company_id_3&amp;gt;&lt;BR /&gt;```&lt;/P&gt;
&lt;P&gt;In your case, you would replace the `&amp;lt;company_id_1&amp;gt;`, `&amp;lt;company_id_2&amp;gt;`, and `&amp;lt;company_id_3&amp;gt;`placeholders with the ID values of the companies that you want to get contact records for.&lt;/P&gt;
&lt;P&gt;Here is an example of how to use the API endpoint to get contact records for three companies:&lt;/P&gt;
&lt;P&gt;```&lt;BR /&gt;&lt;A href="https://api.hubapi.com/contacts/v2/contacts?company_ids=1234567890,9876543210,0123456789" target="_blank"&gt;https://api.hubapi.com/contacts/v2/contacts?company_ids=1234567890,9876543210,0123456789&lt;/A&gt;&lt;BR /&gt;```&lt;/P&gt;
&lt;P&gt;This API endpoint will return a JSON response that contains an array of contact objects. Each contact object will contain the contact's data, including the company IDs that the contact is associated with.&lt;/P&gt;
&lt;P&gt;Here is an example of a JSON response that would be returned for the above API request:&lt;/P&gt;
&lt;P&gt;```&lt;BR /&gt;{&lt;BR /&gt;"contacts": [&lt;BR /&gt;{&lt;BR /&gt;"id": "1234567890",&lt;BR /&gt;"company_ids": [&lt;BR /&gt;1234567890,&lt;BR /&gt;9876543210,&lt;BR /&gt;0123456789&lt;BR /&gt;]&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "9876543210",&lt;BR /&gt;"company_ids": [&lt;BR /&gt;9876543210,&lt;BR /&gt;0123456789&lt;BR /&gt;]&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "0123456789",&lt;BR /&gt;"company_ids": [&lt;BR /&gt;0123456789&lt;BR /&gt;]&lt;BR /&gt;}&lt;BR /&gt;]&lt;BR /&gt;}&lt;BR /&gt;```&lt;/P&gt;
&lt;P&gt;Hope this will helps you out. Please mark it as Solution Accepted to help other Community member.&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jun 2023 13:22:38 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Issue-with-Fetching-Contacts-via-API-Contact-Records-associated/m-p/802264#M64564</guid>
      <dc:creator>GRajput</dc:creator>
      <dc:date>2023-06-02T13:22:38Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Fetching Contacts via API (Contact Records associated to Multiple Company Records)</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Issue-with-Fetching-Contacts-via-API-Contact-Records-associated/m-p/802321#M64568</link>
      <description>&lt;P&gt;Hey,&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/295598"&gt;@RRazote8&lt;/a&gt;&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":waving_hand:"&gt;👋&lt;/span&gt; Thanks for letting us know! Have a fantastic weekend! — Jaycee&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jun 2023 15:04:34 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Issue-with-Fetching-Contacts-via-API-Contact-Records-associated/m-p/802321#M64568</guid>
      <dc:creator>Jaycee_Lewis</dc:creator>
      <dc:date>2023-06-02T15:04:34Z</dc:date>
    </item>
  </channel>
</rss>

