Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Power Query
Unanswered

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

(0) ShareShare
ReportReport
Posted on 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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Power Query

#1
mmbr1606 Profile Picture

mmbr1606 9 Super User 2025 Season 1

#2
SD-13050734-0 Profile Picture

SD-13050734-0 6

#3
stampcoin Profile Picture

stampcoin 2

Overall leaderboard

Featured topics