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.
mmbr1606
9
Super User 2025 Season 1
SD-13050734-0
6
stampcoin
2