<?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: Associations API has started sometimes returning 400 Bad Request in CMS Development</title>
    <link>https://community.hubspot.com/t5/CMS-Development/Associations-API-has-started-sometimes-returning-400-Bad-Request/m-p/416011#M21603</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/169657"&gt;@mathew_murphy&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the mention&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/13982"&gt;@dennisedson&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I read your story, I have some questions:&lt;/P&gt;&lt;P&gt;What programming language are u using?&lt;BR /&gt;Is your programming language asynchronous or synchronous?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What is the exact response you get on the&amp;nbsp;&lt;SPAN&gt;associations API? In the response body is a message with the error.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;You are talking about code that creates a company for new records. That's code from your own application i guess?&lt;BR /&gt;&lt;BR /&gt;At this moment, with the provided information I think you have some timing issues in your application. Requests are maybe not finished yet or something like that.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Greets Ronald&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 08 Mar 2021 19:00:52 GMT</pubDate>
    <dc:creator>RMones</dc:creator>
    <dc:date>2021-03-08T19:00:52Z</dc:date>
    <item>
      <title>Associations API has started sometimes returning 400 Bad Request</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Associations-API-has-started-sometimes-returning-400-Bad-Request/m-p/415623#M21581</link>
      <description>&lt;P&gt;The associations API has started sometimes returning &lt;EM&gt;400 Bad Request&lt;/EM&gt; to our code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code runs when a new user is registered in our application. First, we look up the contact by e-mail. If there's no contact, we create one. Next, we PATCH some changes to the contact whether it existed or not.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then, we attempt to look for company records associated with the contact. This is the part that's failing. The request is a simple GET:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;GET /crm/v3/objects/contacts/NNNN/associations/company&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;where NNNN is the HubSpot ID of the contact record, which may have just been created at the time of the call.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When we get 400 Bad Request we log the ID it was trying to fetch, and if I later call the same function from a unit test, with the same ID value, it works. So it seems there's some time-dependent failure happening when looking up associations for a newly-created contact.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Perhaps the code that automatically creates company records for new contacts is clashing with the associations API service?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What's the right thing to do to avoid the problem?&lt;/P&gt;</description>
      <pubDate>Fri, 05 Mar 2021 21:07:45 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Associations-API-has-started-sometimes-returning-400-Bad-Request/m-p/415623#M21581</guid>
      <dc:creator>mathew_murphy</dc:creator>
      <dc:date>2021-03-05T21:07:45Z</dc:date>
    </item>
    <item>
      <title>Re: Associations API has started sometimes returning 400 Bad Request</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Associations-API-has-started-sometimes-returning-400-Bad-Request/m-p/416005#M21602</link>
      <description>&lt;P&gt;Hey &lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/169657"&gt;@mathew_murphy&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a feeling that you are beating the system to the punch and the contact hasnt been fully registered, yet.&lt;/P&gt;
&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/154476"&gt;@RMones&lt;/a&gt; , what do you think?&lt;/P&gt;</description>
      <pubDate>Mon, 08 Mar 2021 18:49:18 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Associations-API-has-started-sometimes-returning-400-Bad-Request/m-p/416005#M21602</guid>
      <dc:creator>dennisedson</dc:creator>
      <dc:date>2021-03-08T18:49:18Z</dc:date>
    </item>
    <item>
      <title>Re: Associations API has started sometimes returning 400 Bad Request</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Associations-API-has-started-sometimes-returning-400-Bad-Request/m-p/416011#M21603</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/169657"&gt;@mathew_murphy&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the mention&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/13982"&gt;@dennisedson&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I read your story, I have some questions:&lt;/P&gt;&lt;P&gt;What programming language are u using?&lt;BR /&gt;Is your programming language asynchronous or synchronous?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What is the exact response you get on the&amp;nbsp;&lt;SPAN&gt;associations API? In the response body is a message with the error.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;You are talking about code that creates a company for new records. That's code from your own application i guess?&lt;BR /&gt;&lt;BR /&gt;At this moment, with the provided information I think you have some timing issues in your application. Requests are maybe not finished yet or something like that.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Greets Ronald&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Mar 2021 19:00:52 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Associations-API-has-started-sometimes-returning-400-Bad-Request/m-p/416011#M21603</guid>
      <dc:creator>RMones</dc:creator>
      <dc:date>2021-03-08T19:00:52Z</dc:date>
    </item>
    <item>
      <title>Re: Associations API has started sometimes returning 400 Bad Request</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Associations-API-has-started-sometimes-returning-400-Bad-Request/m-p/416299#M21628</link>
      <description>&lt;P&gt;I tracked down the whole HTTP response in the logs, and it turns out the error message had been misidentifying which operation had failed. I now know what's going on, and how to fix it. Not a problem with associations after all! Sorry for the misinformation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There &lt;EM&gt;is&lt;/EM&gt; a problem with timing when creating contacts and then trying to fetch associated companies, but it's fixable by making the client pause for a second or two to let HubSpot finish what it was doing. (The whole sequence is running synchronously.) I'd already put that pause in, but I was wondering why it was still failing.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Mar 2021 14:53:39 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Associations-API-has-started-sometimes-returning-400-Bad-Request/m-p/416299#M21628</guid>
      <dc:creator>mathew_murphy</dc:creator>
      <dc:date>2021-03-09T14:53:39Z</dc:date>
    </item>
  </channel>
</rss>

