I’m having issues batch creating line items when there are multiple duplicate line items. HubSpot is removing my duplicate line items.
Ex: I am sending 10 line items, but 7 are exactly the same. HubSpot response is 5 line items. HubSPot consolidates repeated line items into a single line item with quantity set to 1.
How can I ensure that all line items, including duplicates, are imported?
Here is my function:
def create_batch_line_items(self, deal_id, line_items): """ Create multiple line items in HubSpot :param deal_id: Deal ID :param line_items: List of line items """ from hubspot.crm.line_items import BatchInputSimplePublicObjectInputForCreate, ApiException hubspot_line_items = [] for item in line_items: hubspot_item = { "associations": [ { "to": {"id": deal_id}, "types": [{"associationCategory": "HUBSPOT_DEFINED", "associationTypeId": 20}] } ], "properties": { "hs_sku": item['hs_sku'], "name": item['name'], "quantity": item['quantity'], "price": item['price'], # Convert cents to dollars # Convert cents to dollars "hs_cost_of_goods_sold": item['cost'], "hs_line_item_currency_code": "NZD", "supplier_name": item.get('supplier_name', '') } } hubspot_line_items.append(hubspot_item) batch_input_simple_public_object_input_for_create = BatchInputSimplePublicObjectInputForCreate( inputs=hubspot_line_items) try: response = self.client.crm.line_items.batch_api.create( batch_input_simple_public_object_input_for_create=batch_input_simple_public_object_input_for_create) return response.results except ApiException as e: print("Exception when calling line_items_api->create: %s\n" % e)
original line items
returned line items













