Not able to import duplicate line items

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

Hi, @Andre3 :waving_hand: Thanks for your post and for including your details. I’d like to invite some of our community members to the conversation — hey @Anton @dsmarion @Mike_Eastwood, do you have any suggestions for @Andre3?

Thank you very much for taking a look! — Jaycee

Hi @Andre3

SKU is the unique identifier here so it needs to be changed for every call. You can’t create line items with the same SKU other than that you can create line items with the same name for reference you can see SS.

If this doesn’t solve your problem please explain in detail what you mean by duplicate line item, with the properties which are the same and which are not.

I hope this will help you out. Please mark it as Solution Accepted and upvote to help another Community member.
Thanks!

Thanks. We have decided to add a suffix to each repeated line item SKU, which will solve our problem.

Hi Andre,

You can create duplicate line items if you send separate API requests to create each of them, and then one more API request to assign them to a deal. As an example, we created 10 line items with 10 API request (please see screenshots of API request and API response for the first two of them below), and then used 11th API request to assign those to the deal (the screenshot of the API request and API response attached).

You can contact us here if you’d need more support with line items migration.