I'm a complete PowerBI novice - though it looks like just what I need in order to start doing some more robust analytics on our Hubspot marketing and CRM.
However I'm falling at the first hurdle of getting paginated data from the HubSpot API. Hubspot limits each call to 250 results and has a 'has-more' bool value - which I'm trying to use to identify calling the next offset (which does not increase steadily, it ends up being a number like '4383292039').
I've been reading lots of posts and trying to get example code to work. I feel like I'm close but I keep getting 'The field 'WebCall' of the record wasn't found' in the below:
let Pagination = List.Skip(List.Generate( () => [Last_Key = 0, Counter = 0], // Start Value each [Last_Key] <> null, // Condition under which the next execution will happen each [ WebCall = Json.Document(Web.Contents("https://api.hubapi.com/companies/v2/companies/paged?hapikey=" & #"Hubspot API Key" & "&properties=name&properties=website&limit=250&offset=" & Text.From([Last_Key]) & "")), // retrieve results per call Last_Key = try if [WebCall][hasMore] = true then [WebCall][offset] else null, Counter = [Counter]+1,// internal counter Table = Table.FromRecords([WebCall][offset]) // steps of your further query ] ,each [Table] ) ,1) // in // Pagination , Custom1 = Table.Combine(Pagination) in Custom1
Any help would be much appreciated - I've been plugging away at various iterations of this for hours now and can't seem to figure it out. On that point - what is the best way to debug something like the above?