Deals and Products Importing Natively and API Clarification


#1

Hi,

Hoping to confirm some expected behavior with HS UI and also find a way to associate deals with products via the API

  1. Testing importing products into HubSpot. Can you confirm you can only import (name, product description, product price, cost of goods sold) When doing the import it shows that you can map terms but the reality is it does not let you import terms it gives an error. It seems it's forcing you to manually add it which can't work for 100's of deals.Any reason why the UI is displaying this then in the import screen when it can't be imported

Video of this process:https://share.vidyard.com/watch/iGLiFMeBjD47nFyUDGQzhY?

2)Looking to associate deals with products via an import. Not sure how to go about this. Was looking at this endpoint here(https://developers.hubspot.com/docs/methods/crm-associations/associate-objects) and was hoping you could provide more insight on the setup in postman. I see there was a conversation going on with this here(Get Products Associated with Deals via API) and was reading through but kinda stuck just testing a setting up a basic deal and product so I can try and scale this for multiple deals and products.Would you be able to provide an example of any deal and product association being sent to HubSpot via the associate crm object endpoint?


#3

Hey @karlon! Welcome and congrats on the new job! So this first part was tricky. Looks like the products import takes a very specific format for the Term property. Since it's available in the import screen to select from, we can definitely write to it. I found out the format by using a GET request to the CRM properties api to find the internal name of Term, then used it in another GET request to the GET all products endpoint. The way that the values in the Term property need to be formatted are as follows.

For monthly terms:
P{number goes here}M
For yearly terms:
P{number goes here}Y

So for example, here's how my CSV looks:

For the second issue, there's actually a misconception here. You cannot actually associate Deals with Products. You must associate Deals with Line Items. Line items are instances of a product.

In order to do this, we'd make a PUT request to this endpoint:

https://api.hubapi.com/crm-associations/v1/associations?hapikey=XXXXXXXX

with a body of:

{
  "fromObjectId": { DEAL ID HERE },
  "toObjectId": { LINE ITEM ID HERE },
  "category": "HUBSPOT_DEFINED",
  "definitionId": 19
}

Here's a screenshot of my setup in postman:

And here's a screenshot of the successful association:


#4

I hope all is well with you Connor. Thanks and thanks!