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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Getting the last page ...
Power Apps
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.

Categories:

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 394 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 324 Most Valuable Professional

Last 30 days Overall leaderboard