APIs & Integrations

IWebster
Participant

API - Batch read deals and include line items

SOLVE

Hi all,

 

I'm trying to figure out how I would get a list of specific deals and include their line items in the result set.

 

I can see on this end point /crm/v3/objects/deals that you can use the "associations" parameter to tell the API to include line items, however I'm struggling to recreate this behaviour on the batch read deals end point.

 

Here's where I am at;

 

I'm posting to /crm/v3/objects/deals/batch/read with the following JSON;

 

 

 

{
    "properties": [
        "hs_object_id", "associations"
    ],
    "inputs": [
        {
            "id": 5557441801
        },
                {
            "id": 5557441822
        },
                {
            "id": 5557441950
        }
    ]    
}

 

 

 

I've also tried "line_items" as a property, in both cases I just get the following back;

 

 

 

{
    "status": "COMPLETE",
    "results": [
        {
            "id": "5557441801",
            "properties": {
                "createdate": "2021-06-28T14:51:37.466Z",
                "hs_lastmodifieddate": "2021-06-28T15:06:22.338Z",
                "hs_object_id": "5557441801"
            },
            "createdAt": "2021-06-28T14:51:37.466Z",
            "updatedAt": "2021-06-28T15:06:22.338Z",
            "archived": false
        }
    ],
    "startedAt": "2021-06-29T07:20:42.994Z",
    "completedAt": "2021-06-29T07:20:43.011Z"
}

 

 

 

no line items.

 

If what I am trying to do is not possible is there a way to get line items by association with deals? - i.e. I provide a list of deal id's as the search criteria and get back a list of line items matching the criteria.

 

Thanks,

 

Ian.

0 Upvotes
2 Accepted solutions
IWebster
Solution
Participant

API - Batch read deals and include line items

SOLVE

Hi @dennisedson,

 

Thanks for the response, yeah I've looked into associations API, I was hoping to avoid the extra call required to first get deals then a call to associations to get the line items (and then again to get the actual line items!) seems wasteful but after doing a lot of reading it looks like there isn't any other options.

 

Not sure if you'd know this but out of interest is there any plans to introduce GraphQL? it would be nice to be able to just define what I wanted from the API in a single call rather than have to make multiple calls to get all the data I wanted.

 

Thanks,

 

Ian.

View solution in original post

dennisedson
Solution
HubSpot Product Team
HubSpot Product Team

API - Batch read deals and include line items

SOLVE

We are definitely exploring GraphQL! 

I don't have much more to offer than that other than stay tuned 👀.  Terrible cliff hanger...

View solution in original post

0 Upvotes
4 Replies 4
kastraver
Contributor

API - Batch read deals and include line items

SOLVE

Edit: This idea is much bigger and in review, so please do put your two cents there! https://community.hubspot.com/t5/HubSpot-Ideas/Filter-Deals-by-associated-Products/idc-p/498783

 

There's an idea here https://community.hubspot.com/t5/HubSpot-Ideas/Search-line-items-in-all-quotes-and-deals/idc-p/49874... to be able to search Deals based on Line Item. I believe this would also enable you to export Deals with Line Item information. Please do upvote so that we no longer have to rely on an API!

dennisedson
HubSpot Product Team
HubSpot Product Team

API - Batch read deals and include line items

SOLVE

Hey @IWebster ,

Have you looked at the associations API?

You aren't getting the line items in the properties because they aren't properties.  Instead, they are their own object.

0 Upvotes
IWebster
Solution
Participant

API - Batch read deals and include line items

SOLVE

Hi @dennisedson,

 

Thanks for the response, yeah I've looked into associations API, I was hoping to avoid the extra call required to first get deals then a call to associations to get the line items (and then again to get the actual line items!) seems wasteful but after doing a lot of reading it looks like there isn't any other options.

 

Not sure if you'd know this but out of interest is there any plans to introduce GraphQL? it would be nice to be able to just define what I wanted from the API in a single call rather than have to make multiple calls to get all the data I wanted.

 

Thanks,

 

Ian.

dennisedson
Solution
HubSpot Product Team
HubSpot Product Team

API - Batch read deals and include line items

SOLVE

We are definitely exploring GraphQL! 

I don't have much more to offer than that other than stay tuned 👀.  Terrible cliff hanger...

0 Upvotes