<?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 Getting a “400 Bad Request” when trying to create a deal in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/Getting-a-400-Bad-Request-when-trying-to-create-a-deal/m-p/266569#M23902</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm creating deals in my Ruby on Rails application and everything's been working fine for months. But two days ago (22nd April 2019), I started getting a 400 Bad Request response despite making no changes to my application.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Has anything changed with the API?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;endpoint = "&lt;A href="https://api.hubapi.com/deals/v1/deal?hapikey=#{ENV[&amp;quot;hubspot_api_key" target="_blank" rel="noopener"&gt;https://api.hubapi.com/deals/v1/deal?hapikey=#{ENV["hubspot_api_key&lt;/A&gt;"]}"&lt;/P&gt;&lt;P&gt;payload = {&lt;BR /&gt;associations: {&lt;BR /&gt;associatedVids: [vid]&lt;BR /&gt;},&lt;BR /&gt;properties: [&lt;BR /&gt;{&lt;BR /&gt;value: "#{enquiry}",&lt;BR /&gt;name: "dealname"&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;value: "#{valid_internal_hubspot_reference}",&lt;BR /&gt;name: "dealstage"&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;value: "#{valid_internal_hubspot_reference}",&lt;BR /&gt;name: "pipeline"&lt;BR /&gt;}&lt;BR /&gt;]&lt;BR /&gt;}.to_json&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;uri = URI.parse(endpoint)&lt;BR /&gt;header = {'Content-Type': 'application/json'}&lt;BR /&gt;http = Net::HTTP.new(uri.host, uri.port)&lt;BR /&gt;http.use_ssl = true&lt;BR /&gt;http.verify_mode = OpenSSL::SSL::VERIFY_NONE&lt;BR /&gt;request = Net::HTTP::Post.new(uri.request_uri, header)&lt;BR /&gt;request.body = payload&lt;BR /&gt;response = http.request(request)&lt;BR /&gt;return response&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 24 Apr 2019 15:03:34 GMT</pubDate>
    <dc:creator>GaryElliott</dc:creator>
    <dc:date>2019-04-24T15:03:34Z</dc:date>
    <item>
      <title>Getting a “400 Bad Request” when trying to create a deal</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Getting-a-400-Bad-Request-when-trying-to-create-a-deal/m-p/266569#M23902</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm creating deals in my Ruby on Rails application and everything's been working fine for months. But two days ago (22nd April 2019), I started getting a 400 Bad Request response despite making no changes to my application.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Has anything changed with the API?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;endpoint = "&lt;A href="https://api.hubapi.com/deals/v1/deal?hapikey=#{ENV[&amp;quot;hubspot_api_key" target="_blank" rel="noopener"&gt;https://api.hubapi.com/deals/v1/deal?hapikey=#{ENV["hubspot_api_key&lt;/A&gt;"]}"&lt;/P&gt;&lt;P&gt;payload = {&lt;BR /&gt;associations: {&lt;BR /&gt;associatedVids: [vid]&lt;BR /&gt;},&lt;BR /&gt;properties: [&lt;BR /&gt;{&lt;BR /&gt;value: "#{enquiry}",&lt;BR /&gt;name: "dealname"&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;value: "#{valid_internal_hubspot_reference}",&lt;BR /&gt;name: "dealstage"&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;value: "#{valid_internal_hubspot_reference}",&lt;BR /&gt;name: "pipeline"&lt;BR /&gt;}&lt;BR /&gt;]&lt;BR /&gt;}.to_json&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;uri = URI.parse(endpoint)&lt;BR /&gt;header = {'Content-Type': 'application/json'}&lt;BR /&gt;http = Net::HTTP.new(uri.host, uri.port)&lt;BR /&gt;http.use_ssl = true&lt;BR /&gt;http.verify_mode = OpenSSL::SSL::VERIFY_NONE&lt;BR /&gt;request = Net::HTTP::Post.new(uri.request_uri, header)&lt;BR /&gt;request.body = payload&lt;BR /&gt;response = http.request(request)&lt;BR /&gt;return response&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Apr 2019 15:03:34 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Getting-a-400-Bad-Request-when-trying-to-create-a-deal/m-p/266569#M23902</guid>
      <dc:creator>GaryElliott</dc:creator>
      <dc:date>2019-04-24T15:03:34Z</dc:date>
    </item>
    <item>
      <title>Re: Getting a “400 Bad Request” when trying to create a deal</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Getting-a-400-Bad-Request-when-trying-to-create-a-deal/m-p/266570#M23903</link>
      <description>&lt;P&gt;I have the exact same problem. The contact API is still working but the deal API stopped working 2 days ago and only answers 400 (with no details).&lt;/P&gt;</description>
      <pubDate>Wed, 24 Apr 2019 15:06:52 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Getting-a-400-Bad-Request-when-trying-to-create-a-deal/m-p/266570#M23903</guid>
      <dc:creator>ivandhalluin</dc:creator>
      <dc:date>2019-04-24T15:06:52Z</dc:date>
    </item>
    <item>
      <title>Re: Getting a “400 Bad Request” when trying to create a deal</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Getting-a-400-Bad-Request-when-trying-to-create-a-deal/m-p/266780#M23931</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/81433"&gt;@GaryElliott&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/92828"&gt;@ivandhalluin&lt;/a&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm sorry to hear that you're encountering issues.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you confirm whether the same requests produce&amp;nbsp;&lt;CODE&gt;400&lt;/CODE&gt; errors in a REST client like Postman?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Additionally, could you each define the Hub IDs in which you are attempting to create deals and provide dummy payloads which are consistently throwing&amp;nbsp;&lt;CODE&gt;400&lt;/CODE&gt; errors in your Ruby applications? (If the results differ in a REST client, please let me know.)&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2019 16:08:51 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Getting-a-400-Bad-Request-when-trying-to-create-a-deal/m-p/266780#M23931</guid>
      <dc:creator>IsaacTakushi</dc:creator>
      <dc:date>2019-04-25T16:08:51Z</dc:date>
    </item>
    <item>
      <title>Re: Getting a “400 Bad Request” when trying to create a deal</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Getting-a-400-Bad-Request-when-trying-to-create-a-deal/m-p/266786#M23934</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/665"&gt;@IsaacTakushi&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't get any errors when submitted via Postman.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hub ID =&amp;nbsp;3818569&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Payload:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt;"associations": {&lt;BR /&gt;"associatedVids": [&lt;BR /&gt;19328551&lt;BR /&gt;]&lt;BR /&gt;},&lt;BR /&gt;"properties": [&lt;BR /&gt;{&lt;BR /&gt;"value": "Test - Test",&lt;BR /&gt;"name": "dealname"&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"value": "706ab8a3-219f-4557-a010-de1a0214d96b",&lt;BR /&gt;"name": "dealstage"&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"value": "206d1d85-19d6-4c1b-877f-8342bef3e0b7",&lt;BR /&gt;"name": "pipeline"&lt;BR /&gt;}&lt;BR /&gt;]&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sending this payload in Postman doesn't return any errors.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2019 16:22:26 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Getting-a-400-Bad-Request-when-trying-to-create-a-deal/m-p/266786#M23934</guid>
      <dc:creator>GaryElliott</dc:creator>
      <dc:date>2019-04-25T16:22:26Z</dc:date>
    </item>
    <item>
      <title>Re: Getting a “400 Bad Request” when trying to create a deal</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Getting-a-400-Bad-Request-when-trying-to-create-a-deal/m-p/266797#M23936</link>
      <description>&lt;P&gt;It's the same thing for me, failing in Rails (using&amp;nbsp;&lt;SPAN&gt;HTTParty&lt;/SPAN&gt;). But working in postman with this body on&amp;nbsp;5651313 :&lt;/P&gt;&lt;PRE&gt;{"associations":{"associatedCompanyIds":[],"associatedVids":["2091301"]},"properties":[{"name":"pipeline","value":"default"},{"name":"dealstage","value":"appointmentscheduled"}]}&lt;/PRE&gt;&lt;P&gt;But the same methods (via Rails) are working for contacts (POST&amp;nbsp;&lt;SPAN&gt;"/contacts/v1/contact"&lt;/SPAN&gt;).&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2019 16:38:52 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Getting-a-400-Bad-Request-when-trying-to-create-a-deal/m-p/266797#M23936</guid>
      <dc:creator>ivandhalluin</dc:creator>
      <dc:date>2019-04-25T16:38:52Z</dc:date>
    </item>
    <item>
      <title>Re: Getting a “400 Bad Request” when trying to create a deal</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Getting-a-400-Bad-Request-when-trying-to-create-a-deal/m-p/267313#M24007</link>
      <description>&lt;P&gt;Ok, found the issue.&lt;BR /&gt;HTTParty was not sending the proper Content-Type :&amp;nbsp;&lt;A href="https://github.com/jnunemaker/httparty/issues/472" target="_blank"&gt;https://github.com/jnunemaker/httparty/issues/472&lt;/A&gt;&lt;BR /&gt;Switching to this syntax solved it for me:&lt;/P&gt;&lt;PRE&gt;headers: { 'Content-Type' =&amp;gt; 'application/json' }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;The thing is that it was working for the other endpoints (and this one, before the 22 of april) without sending the good Content-Type.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2019 09:20:53 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Getting-a-400-Bad-Request-when-trying-to-create-a-deal/m-p/267313#M24007</guid>
      <dc:creator>ivandhalluin</dc:creator>
      <dc:date>2019-04-29T09:20:53Z</dc:date>
    </item>
    <item>
      <title>Re: Getting a “400 Bad Request” when trying to create a deal</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Getting-a-400-Bad-Request-when-trying-to-create-a-deal/m-p/267314#M24008</link>
      <description>&lt;P&gt;I've been setting this header all along:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;header = {'Content-Type': 'application/json'}&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2019 09:23:24 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Getting-a-400-Bad-Request-when-trying-to-create-a-deal/m-p/267314#M24008</guid>
      <dc:creator>GaryElliott</dc:creator>
      <dc:date>2019-04-29T09:23:24Z</dc:date>
    </item>
    <item>
      <title>Re: Getting a “400 Bad Request” when trying to create a deal</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Getting-a-400-Bad-Request-when-trying-to-create-a-deal/m-p/267315#M24009</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just switch from&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;{'Content-Type': 'application/json'}&lt;/PRE&gt;&lt;P&gt;To&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;{'Content-Type' =&amp;gt; 'application/json'}&lt;/PRE&gt;&lt;P&gt;And it should be good&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2019 09:27:52 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Getting-a-400-Bad-Request-when-trying-to-create-a-deal/m-p/267315#M24009</guid>
      <dc:creator>ivandhalluin</dc:creator>
      <dc:date>2019-04-29T09:27:52Z</dc:date>
    </item>
    <item>
      <title>Re: Getting a “400 Bad Request” when trying to create a deal</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Getting-a-400-Bad-Request-when-trying-to-create-a-deal/m-p/267316#M24010</link>
      <description>&lt;P&gt;Seemed to do the trick. So bizarre this would matter all of a sudden.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2019 09:41:06 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Getting-a-400-Bad-Request-when-trying-to-create-a-deal/m-p/267316#M24010</guid>
      <dc:creator>GaryElliott</dc:creator>
      <dc:date>2019-04-29T09:41:06Z</dc:date>
    </item>
    <item>
      <title>Re: Getting a “400 Bad Request” when trying to create a deal</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Getting-a-400-Bad-Request-when-trying-to-create-a-deal/m-p/267326#M24013</link>
      <description>&lt;P&gt;Nice find,&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/92828"&gt;@ivandhalluin&lt;/a&gt;!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That is strange. I'll ask the team if they have insight into why the behavior might have changed...&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2019 12:32:24 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Getting-a-400-Bad-Request-when-trying-to-create-a-deal/m-p/267326#M24013</guid>
      <dc:creator>IsaacTakushi</dc:creator>
      <dc:date>2019-04-29T12:32:24Z</dc:date>
    </item>
    <item>
      <title>Re: Getting a “400 Bad Request” when trying to create a deal</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Getting-a-400-Bad-Request-when-trying-to-create-a-deal/m-p/267455#M24036</link>
      <description>&lt;P&gt;Hey,&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/81433"&gt;@GaryElliott&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/92828"&gt;@ivandhalluin&lt;/a&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As Ivan found, HTTParty was improperly setting the&amp;nbsp;&lt;CODE&gt;Content-Type&lt;/CODE&gt; header with&amp;nbsp;&lt;CODE&gt;{'Content-Type': 'application/json'}&lt;/CODE&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From what I can tell, our team made an update to the Deals API on April 22, triggering &lt;CODE&gt;400&lt;/CODE&gt;&amp;nbsp;errors when&amp;nbsp;&lt;CODE&gt;Content-Type&lt;/CODE&gt;&amp;nbsp;is invalid or omitted. Apologies for the confusion!&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2019 19:26:30 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Getting-a-400-Bad-Request-when-trying-to-create-a-deal/m-p/267455#M24036</guid>
      <dc:creator>IsaacTakushi</dc:creator>
      <dc:date>2019-04-29T19:26:30Z</dc:date>
    </item>
  </channel>
</rss>

