API - Batch read deals and include line items

SOLVE
IWebster
Participant

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

Accepted Solutions
IWebster
Solution
Participant

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
Community Manager

We are definitely exploring GraphQL! 

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

Thanks,

Dennis




Check out our Community Developer Blog
where we feature our Community driven developer podcast and how to content

View solution in original post

0 Upvotes
4 Replies 4
dennisedson
Community Manager

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.

Thanks,

Dennis




Check out our Community Developer Blog
where we feature our Community driven developer podcast and how to content
0 Upvotes
IWebster
Solution
Participant

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
Community Manager

We are definitely exploring GraphQL! 

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

Thanks,

Dennis




Check out our Community Developer Blog
where we feature our Community driven developer podcast and how to content

View solution in original post

0 Upvotes
kastraver
Contributor

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!