Associating contact on deal creation API V3

After creating both the deal and the contacts, I am stuck at connecting the deal with the already existing contact.

From what I see in the documentation associations are possible directly on create (Accounts Dashboard | HubSpot)

However when I create a deal with an association to the contact as stated in the documentaion, the deal gets created without errors, but the association not. Below are the params:

request_body = {:properties=>{:dealname=>“Ioana Bob - Couple DE”, :amount=>0.8e5, :dealstage=>170367959, :pipeline=>“default”, :hubspot_owner_id=>“834297809”},

:associations=>

[{:to=>{:id=>2251}, :types=>[{:associationCategory=>“HUBSPOT_DEFINED”, :associationTypeId=>3}]},

{:associated_objects=>[“CONTACT”]}]}

Ruby API call:

hubspot_api_client.crm.deals.basic_api.create(body: request_body)

Could you share what am I missing here? I attempted to perform the curl request with the association through the website, and I couldn’t make it work in raw format either.

As a note, I would like to avoid making another API call to create the association separately, because it would be a waste of resources.

Hey, @IoanaBob :waving_hand: Welcome to the community! Thanks for your question. Do you still need an example? If so, what you are after is a simple working example of:

  • creating a new Deal
  • associating the new Deal to an existing Contact
  • doing it in one-shot

Is that correct?

Best,

Jaycee