web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id : HliNNL73m6YjQOVOWoaOcx
Power Apps - Power Query
Unanswered

Getting the last page of data from API using List.Generate

Like (0) ShareShare
ReportReport
Posted on 22 Feb 2024 12:51:24 by

Hi,

 

I am getting data from the HubSpot api using Web.Contents, the results are paginated so I loop the call using List.Generate to get all of the data excpt my query isn't getting the last page of data.

 

I started by creting the function FnGetRecords:

 

 

= (optional afterStr as text) =>
let
Source = Json.Document(Web.Contents("https://api.hubapi.com/crm/v3/owners?limit=20&archived=false", [Query=[after=afterStr ?? {}],Headers=[#"Content-Type"="application/json", Authorization="Bearer ############################################"]]))
in
Source

 

 

 

Then List.Generate calls this like so:

= List.Generate(
 () => [hubData = FnGetRecords()],
 each Record.HasFields([hubData],"paging"),
 each [hubData = FnGetRecords([hubData][paging][next][after])]
)

The json returned from HubSpot has results record and if there are more results then it will have a paging record. Once you get the last page then the paging record disappears and you are only sent reults. 

 

I think what is happening is that the call is made to get the last page of data, this is then evaluated and is found not to contain the record paging and so it is not added to the list. What I need it to add that page of data to the list but stop there. Equally I may have made a completely different mistake.

 

Any help would be much appriciated.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410 Super User 2025 Season 2

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 2

Featured topics

Loading complete