APIs & Integrations

Silas
Member | Gold Partner
Member | Gold Partner

Can't add product with custom property to deal

I have created a set of new product properties using the /properties/v2/product/properties endpoint, I then created some products using the /crm-objects/v1/objects/products endpoint, both were successful. When I try to add these products to a deal I get an error "There was an error saving the product changes. Please try again.". If I create a product using the same endpoint and only set the properties name, description, price then I can add the product to a deal.

Any idea what the issue might be?

HubID : 2660145

This is an example of one of the custom properties that is returned when I run the endpoint /properties/v2/products/properties
{
"name": "categories",
"label": "Categories",
"description": "",
"groupName": "vision-properties",
"type": "string",
"fieldType": "text",
"options": ,
"hidden": false,
"deleted": false,
"displayOrder": 1,
"currencyPropertyName": null,
"createdAt": 1547126605340,
"referencedObjectType": null,
"updatedAt": 1547126605340,
"isCustomizedDefault": false,
"searchableInGlobalSearch": false,
"hasUniqueValue": false,
"formField": false,
"readOnlyValue": false,
"readOnlyDefinition": false,
"mutableDefinitionNotDeletable": false,
"favorited": false,
"favoritedOrder": -1,
"calculated": false,
"externalOptions": false,
"displayMode": "current_value",
"showCurrencySymbol": null,
"createdUserId": null,
"textDisplayHint": null,
"numberDisplayHint": null,
"optionsAreMutable": null,
"hubspotDefined": null,
"updatedUserId": null
}

This is an example of what is returned when I run /crm-objects/v1/objects/products/9473591

{
    "objectType": "PRODUCT",
    "portalId": 2660145,
    "objectId": 9473591,
    "properties": {},
    "version": 1,
    "isDeleted": false
}

This is the posted data I am using when creating the product using /crm-objects/v1/objects/products/

[{
    "name": "categories",
    "value": "beer, beer-wine, wine"
},
{
"name": "name",
"value": "A new product"
},
{
"name": "description",
"value": "A description of this product."
},
{
"name": "price",
"value": "27.50"
}]

I am using the API key for authentication.

0 Upvotes
6 Replies 6
cbarley
HubSpot Alumni
HubSpot Alumni

Can't add product with custom property to deal

Hi @silasnielsen, apologies for the delay here, I was out of the office on thursday and friday last week. I spoke with the product team and the reason you cannot attach the product to the deal in the UI is because the product has a custom property on it that does not exist as a custom property on the line item object. Line items are created from products and can be thought of as instantiations of a singular product. Only line items can be attached to deals, and not the products themselves. Th line item needs to have the same property definitions that the products have. If you intend to use line items for products that have a custom property, you should be creating the same custom property on line items as well.

Your flow would look something like this:

  1. Create a custom property on products via API (i.e. create a property called "categories" on the products object)
  2. Create the same custom property on line items via API (i.e. create a property called "categories" on the line items object)
  3. Create a product with a custom property via API (eg. create a product using the "categories" custom property)
  4. Attach that product to a deal in the UI or the API (this should work because the product and line item will both have the custom property definition)
0 Upvotes
Silas
Member | Gold Partner
Member | Gold Partner

Can't add product with custom property to deal

Thanks Connor,

I tested the associations api and it seems to be working as expected. The get product endpoint also seems to work now, I could have sworn it was not, but maybe that was my mistake. Is there a reason that the properties do not show in the UI?

Could you keep me posted on the bug with Adding a product to a deal using the UI?

0 Upvotes
cbarley
HubSpot Alumni
HubSpot Alumni

Can't add product with custom property to deal

HI @silasnielsen, I'll let you know when I have an update on that issue. Associations should be fine, but if you run into issues again let me know. I'm actually not sure why we don't surface custom properties in the UI but can get more info on that.

0 Upvotes
Silas
Member | Gold Partner
Member | Gold Partner

Can't add product with custom property to deal

Hi @Connor_Barley,

I essentially have a few separate issues at the moment:

  1. Adding a product to a deal using the UI : If I create a product via the API with values for 'name', 'description', 'price' properties, then I can add it to a deal. If I create a product with values for 'name', 'description', 'price', 'categories' (custom property described above), then I get an error "There was an error saving the product changes. Please try again.". I have created some examples, on my portal try adding the products titled "Product with categories" and "Product without categories" to this deal https://app.hubspot.com/contacts/2660145/deal/469091787/products

  2. Creating line item via API : I have looked at the line item API, but I do not see how to associate the line item with a deal. I would expect the Create endpoint would support a 'deal_id' property along with 'product_id' but I don't see it documented. https://developers.hubspot.com/docs/methods/line-items/create-line-item

  3. Get properties for product : After I have created a product with the API I use GET on the endpoint /crm-objects/v1/objects/products/9473591 but it returns no product properties. You can see the response in the example above.

Let me know if I can provide any additional information that might help in diagnosing these issues.

0 Upvotes
cbarley
HubSpot Alumni
HubSpot Alumni

Can't add product with custom property to deal

Hi @silasnielsen, thanks for that additional info. I was able to reproduce the issue you're seeing for #1, so this definitely seems like a bug to me. I've reached out to the team about this already.

  1. My fault on this one, I forgot to mention the Assocations API. The create endpoint on line items does not support adding a deal_id. Instead you'll need to create the line item, then use the Associations API to associate the line item to the deal.
  2. With the GET to a specific product endpoint, you'll need to specify which properties you'd like returned back to you. By default, we don't return properties back to you with this endpoint. See the second example in the right sidebar here: https://developers.hubspot.com/docs/methods/products/get_product_by_id
0 Upvotes
cbarley
HubSpot Alumni
HubSpot Alumni

Can't add product with custom property to deal

Hi @silasnielsen, are you trying to associate a product with a deal via the API or via the user interface? If so, I'm able to see that this product is being returned back to me when viewing all products here: https://app.hubspot.com/settings/2660145/sales/products and it's name is "A new product":

You have four products under the same name, but all 4 of them I was able to see in the UI when trying to attach them to a deal. If you're looking to attach them via the API, you'll need to use the Line Items API, as a product is just what appears in the product library, but a line item is what you're able to attach to a deal as you can think of them as instances of a product

0 Upvotes