APIs & Integrations

DRousselin
Participante

API V3 Batch Create Associations is not working as expected

resolver

Hello,

I'm currently struggling with the HubSpot support team because they can't understand a single request.

I'm using the Batch Create Associations endpoint from V3 API : /crm/v3/associations/deal/line_item/batch/create

I'm trying to associate line items to deals.

First of all, you can't associate multiple line items to multiple deals at once, this is tricky when you know that you are using a BATCH function.

So, you need to proceed by deal and make 1 API Call per deal to associate multiple line items.

I have the following Payloads and API Responses :

Payload 1 :

{
	"inputs": [
		{
			"from": {
				"id": "3961097101"
			},
			"to": {
				"id": "1080141388"
			},
			"type": "deal_to_line_item"
		},
		{
			"from": {
				"id": "3961097101"
			},
			"to": {
				"id": "1004976138"
			},
			"type": "deal_to_line_item"
		}
	]
}

 
 Payload 2 :

{
	"inputs": [
		{
			"from": {
				"id": "3961035447"
			},
			"to": {
				"id": "1080141388"
			},
			"type": "deal_to_line_item"
		},
		{
			"from": {
				"id": "3961035447"
			},
			"to": {
				"id": "1004976138"
			},
			"type": "deal_to_line_item"
		}
	]
}

 

API Response 1 :

{
  "status": "COMPLETE",
  "results": [
    {
      "from": {
        "id": "3961097101"
      },
      "to": {
        "id": "1004976138"
      },
      "type": "deal_to_line_item"
    },
    {
      "from": {
        "id": "1080141388"
      },
      "to": {
        "id": "3961097101"
      },
      "type": "line_item_to_deal"
    },
    {
      "from": {
        "id": "3961097101"
      },
      "to": {
        "id": "1080141388"
      },
      "type": "deal_to_line_item"
    },
    {
      "from": {
        "id": "1004976138"
      },
      "to": {
        "id": "3961097101"
      },
      "type": "line_item_to_deal"
    }
  ],
  "startedAt": "2021-01-20T10:17:24.909Z",
  "completedAt": "2021-01-20T10:17:24.959Z"
}


API Response 2 :

{
  "status": "COMPLETE",
  "results": [
    {
      "from": {
        "id": "3961035447"
      },
      "to": {
        "id": "1080141388"
      },
      "type": "deal_to_line_item"
    },
    {
      "from": {
        "id": "3961035447"
      },
      "to": {
        "id": "1004976138"
      },
      "type": "deal_to_line_item"
    },
    {
      "from": {
        "id": "1004976138"
      },
      "to": {
        "id": "3961035447"
      },
      "type": "line_item_to_deal"
    },
    {
      "from": {
        "id": "1080141388"
      },
      "to": {
        "id": "3961035447"
      },
      "type": "line_item_to_deal"
    }
  ],
  "startedAt": "2021-01-20T10:17:25.938Z",
  "completedAt": "2021-01-20T10:17:25.993Z"
}

 
As you can see, both requests seems correct according to the responses.

When I check if the associations are correctly set, there is a problem, I only get the associations on the second object and not the first object.

If I try to set associations on the first object, the associations are present.

If I try to set associations on the second object, the associations are removed from the first object and added to the second object.

If I try to associate them without the batch method, it works perfectly.

There is definitely a BUG inside the batch method.

It's been now 9 working days and the problem is still not solved.

0 Avaliação positiva
1 Solução aceita
zwolfson
Solução
HubSpot Employee
HubSpot Employee

API V3 Batch Create Associations is not working as expected

resolver

Hi @DRousselin,

 

Thanks for providing the examples. It looks like you are attempting to associate a line_item to multiple deals across your two different calls. A line_item is only able to be associated to a single deal, which is why you are seeing the assocaition move. 

I tested out the behavior of the non-batch API and that also moved the association from the deal it was previously on to the one specificed in my API call. 

 

If you have any examples of a line_item being associated to multiple deals, please send them my way (feel free to DM if you don't feel comfortable sharing here) as that would be a bug.

 

Thanks,
Zack

Exibir solução no post original

3 Respostas 3
zwolfson
Solução
HubSpot Employee
HubSpot Employee

API V3 Batch Create Associations is not working as expected

resolver

Hi @DRousselin,

 

Thanks for providing the examples. It looks like you are attempting to associate a line_item to multiple deals across your two different calls. A line_item is only able to be associated to a single deal, which is why you are seeing the assocaition move. 

I tested out the behavior of the non-batch API and that also moved the association from the deal it was previously on to the one specificed in my API call. 

 

If you have any examples of a line_item being associated to multiple deals, please send them my way (feel free to DM if you don't feel comfortable sharing here) as that would be a bug.

 

Thanks,
Zack

DRousselin
Participante

API V3 Batch Create Associations is not working as expected

resolver

Hello,

I'm pretty sure, I was able to associate multiple line items to multiple deals earlier. I checked again, and it moves the association as you said.

I have some deals to import with some products to attach by using line items, is there any way to automatically create line items and associate them to deals ?

Thanks,
Davy

0 Avaliação positiva
dennisedson
Equipe de Produto da HubSpot
Equipe de Produto da HubSpot

API V3 Batch Create Associations is not working as expected

resolver

Hey @DRousselin 

Sorry that you are having issues.  I will review with the internal team to see where this is.

In the interim, will throw some other community folks into this and see if they have experienced a similar issue or know of a solve

@jpsanchez , @HenryCipolla , @malcolm1 , @Bryantworks  have you noticed an issue with something like this?

0 Avaliação positiva