APIs & Integrations

konyaev
Membro

Associate product as line item to deal

resolver

How can I associate product as line item to deal?

Tried this way 

 

curl --request POST \
  --url 'https://api.hubapi.com/crm/v3/associations/deal/product/batch/create?hapikey=q1w2e3' \
  --header 'content-type: application/json' \
  --data '{
  "inputs": [
    {
      "from": {
        "id": "1"
      },
      "to": {
        "id": "2"
      },
      "type": "line_item_to_deal"
    }
  ]
}'

 

and got next error:

 

{
  "status": "COMPLETE",
  "results": [],
  "numErrors": 1,
  "errors": [
    {
      "status": "error",
      "category": "VALIDATION_ERROR",
      "subCategory": "crm.associations.INVALID_ASSOCIATION_TYPE",
      "message": "line_item_to_deal is not a valid association type between deals and products",
      "context": {
        "type": [
          "line_item_to_deal"
        ],
        "fromObjectType": [
          "deals"
        ],
        "toObjectType": [
          "products"
        ]
      }
    }
  ],
  "startedAt": "2022-07-12T18:04:25.631Z",
  "completedAt": "2022-07-12T18:04:25.662Z"
}

 

0 Avaliação positiva
1 Solução aceita
Jaycee_Lewis
Solução
Gerente da Comunidade
Gerente da Comunidade

Associate product as line item to deal

resolver

Hey, @konyaev Is this still occurring for you? 👋 

 

I recreated your steps, and I am getting a successful response. Here's what I did:

  • I followed this guide from @himanshurauthan on how to generate a Product and Line Item via the API 
  • I used the v3 endpoint from your original post 
    POST /crm/v3/associations/{fromObjectType}/{toObjectType}/batch/create​
  • Here's my request and response:
    curl --request POST \
      --url https://api.hubapi.com/crm/v3/associations/Line_items/Deal/batch/create \
      --header 'authorization: Bearer NOPE' \
      --header 'content-type: application/json' \
      --data '{
      "inputs": [
        {
          "from": {
            "id": "3389121391"
          },
          "to": {
            "id": "9475998565"
          },
          "type": "line_item_to_deal"
        }
      ]
    }'​

    HTTP 201
    
    {
      "status": "COMPLETE",
      "results": [
        {
          "from": {
            "id": "3389121391"
          },
          "to": {
            "id": "9475998565"
          },
          "type": "line_item_to_deal"
        },
        {
          "from": {
            "id": "9475998565"
          },
          "to": {
            "id": "3389121391"
          },
          "type": "deal_to_line_item"
        }
      ],
      "startedAt": "2022-07-13T21:50:33.210Z",
      "completedAt": "2022-07-13T21:50:33.266Z"
    }​
  • I think the difference is you used:
    "fromObjectType": [
              "deals"
            ],
    "toObjectType": [
              "products"​

    and I used Line_items and Deals:

    Line_items_to_Deals.png

I hope this is helpful in getting you on your way.

 

Happy coding! — Jaycee 

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

Exibir solução no post original

1 Resposta 1
Jaycee_Lewis
Solução
Gerente da Comunidade
Gerente da Comunidade

Associate product as line item to deal

resolver

Hey, @konyaev Is this still occurring for you? 👋 

 

I recreated your steps, and I am getting a successful response. Here's what I did:

  • I followed this guide from @himanshurauthan on how to generate a Product and Line Item via the API 
  • I used the v3 endpoint from your original post 
    POST /crm/v3/associations/{fromObjectType}/{toObjectType}/batch/create​
  • Here's my request and response:
    curl --request POST \
      --url https://api.hubapi.com/crm/v3/associations/Line_items/Deal/batch/create \
      --header 'authorization: Bearer NOPE' \
      --header 'content-type: application/json' \
      --data '{
      "inputs": [
        {
          "from": {
            "id": "3389121391"
          },
          "to": {
            "id": "9475998565"
          },
          "type": "line_item_to_deal"
        }
      ]
    }'​

    HTTP 201
    
    {
      "status": "COMPLETE",
      "results": [
        {
          "from": {
            "id": "3389121391"
          },
          "to": {
            "id": "9475998565"
          },
          "type": "line_item_to_deal"
        },
        {
          "from": {
            "id": "9475998565"
          },
          "to": {
            "id": "3389121391"
          },
          "type": "deal_to_line_item"
        }
      ],
      "startedAt": "2022-07-13T21:50:33.210Z",
      "completedAt": "2022-07-13T21:50:33.266Z"
    }​
  • I think the difference is you used:
    "fromObjectType": [
              "deals"
            ],
    "toObjectType": [
              "products"​

    and I used Line_items and Deals:

    Line_items_to_Deals.png

I hope this is helpful in getting you on your way.

 

Happy coding! — Jaycee 

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot