PowerQuery (Excel results) prob with Pagination in Deals API
I'm new to both the HS API and Microsoft Power Query which is part of Excel and more. It was easy to grab the deals using the API but the limit of 250 messes me up. I cannot figure out how to code; I think it's called M-code, in PQ to do the pagination. Any help or even better samples would be amazing. What follows is my existing code minus my API key. All of it was generated by my manipulation of the query results and not hand coded.
While there's isn't a specific example for deals, the mechanism of pagination is the same. In this case, I believe your team can work off through this example:
let
Pagination = List.Skip(List.Generate( () => [IsMore = null, Last_Key = 0, Counter = 0], // Start Value
each [IsMore] <> false,// Whilst this is true, keep going
each [WebCall = Json.Document(Web.Contents("https://api.hubapi.com/contacts/v1/lists/all/contacts/all?" & "hapikey=******" & "&property=firstname" & "&property=lastname" & "&property=createdate" & "&property=email" & "&propertyMode=value_and_history" & "&count=100" & "&vidOffset="&Text.From([Last_Key])&"", [Headers=[ContentType="application/json", Authorization="Bearer Token"]])),// retrieve results per call
Last_Key = try [WebCall][#"vid-offset"] otherwise 0,
IsMore = if [Counter] < 1 then null else [WebCall][#"has-more"],
Counter = [Counter]+1,
Table = Table.FromRecords(WebCall[contacts])
]
,each [Table] // selector
) ,1)
// in
// Pagination
,
Custom1 = Table.Combine(Pagination
You can look into Sprinkle Data in order to grab details from Hubspot to Power BI or any other reporting tool. Alternatively you can use Sprinkle for reporting purpose as well without any extra cost. In short, Sprinkle is your one stop solution for data integration and reporting.