APIs & Integrations

MaximeEsnol
Participant | Elite Partner
Participant | Elite Partner

Pagination on Associations v3 Batch API does not return the next page of associations

SOLVE

Hi, 

 

I am trying to fetch all associated line items of a deal, for this I use the V3 Associations API. The deal I am querying has a lot of line items (268).  According to the documentation, if there are more than 100 associations found, they will be paginated in pages of 100 each. 

 

So I start by making the request below to get the first page of 100 associated line items: 

 

Endpoint: POST https://api.hubapi.com/crm/v3/associations/deal/line_item/batch/read

Request body: 

 

 

{
  "inputs": [
    {
      "id": {{deal_id}}
    }
  ]
}

 

 

The first request runs correctly and returns the first 100 line items associated to the deal. The response also provides the pagination data.

 

When adding the pagination data to the request body, the same 100 associated line items are returned with the same "after" value. So the pagination does not seem to be working on the Associations Batch API.

 

Endpoint: POST https://api.hubapi.com/crm/v3/associations/deal/line_item/batch/read

Request body: 

 

 

{
  "inputs": [
    {
      "id": {{deal_id}}
    }
  ],
  "paging": {
      "next": {
          "after": {{offset_id_from_response}}
      }
  }
}

 

 

However, when querying the endpoint provided by the "link" property, the next 168 associated line items are returned without further pagination. I also noticed that the "link" contains an endpoint from the CRMv3 Objects API and not the Associations API. 

 

Endpoint: GET https://api.hubapi.com/crm/v3/objects/deal/{{deal_id}}/associations/line_items?portalId={{portal_id}...

 

Is it expected behavior that querying associations using the Objects API returns all the associations without pagination? 

 

And regarding the Assocations API, how should the pagination be implemented in the request to get the next set of 100 associated line items? 

 

Thanks in advance and best regards,

Maxime E.

0 Upvotes
1 Accepted solution
MaximeEsnol
Solution
Participant | Elite Partner
Participant | Elite Partner

Pagination on Associations v3 Batch API does not return the next page of associations

SOLVE

@HBrandao 

 

Thank you for having taken the time to reply, the workaround you suggested would not work for my use case because at the time I am querying the associations, I have no way of knowing which are the line item IDs.

 

I have, however, found that by adding a "limit=100" query parameter to the Objects API endpoint (/crm/v3/objects/deal/{{dealId}}/associations/line_items?limit=100), that I can use the pagination correctly.  

View solution in original post

3 Replies 3
HBrandao
Participant

Pagination on Associations v3 Batch API does not return the next page of associations

SOLVE

@MaximeEsnol 

I had the same issue but with the company/contacts association. Firstly, I tried to fetch all the companies assigned to each contact, and I faced the same issue as you. Sadly, I did not find a solution since I am using a get_all() command.

However, once I did the other way around company -> contacts, I was able to get everything since there was a lesser amount of associated records. Maybe that helps you

MaximeEsnol
Solution
Participant | Elite Partner
Participant | Elite Partner

Pagination on Associations v3 Batch API does not return the next page of associations

SOLVE

@HBrandao 

 

Thank you for having taken the time to reply, the workaround you suggested would not work for my use case because at the time I am querying the associations, I have no way of knowing which are the line item IDs.

 

I have, however, found that by adding a "limit=100" query parameter to the Objects API endpoint (/crm/v3/objects/deal/{{dealId}}/associations/line_items?limit=100), that I can use the pagination correctly.  

dennisedson
Community Manager
Community Manager

Pagination on Associations v3 Batch API does not return the next page of associations

SOLVE

@HBrandao 

Any chance you could help out @MaximeEsnol ?


loop Loop Marketing is a new four-stage approach that combines AI efficiency and human authenticity to drive growth.
Learn More

0 Upvotes