Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Combining API Call with two functions (including pagination)

Hi,

I am trying to call an API in Power BI and have run into a roadblock.

 The API parameters only allow 1 site to be entered, so I have created Function 1 and invoked it on a site table (using site email as @hostEmail). But it is only returning 100 records per site.

Following a tutorial, I created Function 2 for pagination (record count unknown) and invoked it on a List query to loop and get all records, but it only works for 1 site.

 

Is it possible to get the pagination working in Function 1?

 

All Site Call - Function 1

-----------------------------------------

(hostEmail as any) => let

    Source = Json.Document(Web.Contents("https://webexapis.com/v1/" & "meetings"

      &"?&hostEmail="&(hostEmail)
      [Headers=[Authorization=List.Min(#"Refresh Token (POST)")]])),

    #"Converted to Table" = Table.FromRecords({Source}),
   #"Removed Columns" = Table.RemoveColumns(#"Inserted Minutes",{"Custom"})

in

    #"Removed Columns"
-----------------------------------------

 

Pagination 

Query using Function 2

-----------------------------------------

= List.Generate(()=>

[Result = try MeetingwOffset(100) otherwise null, Offset=100],

each [Result] <>null,

each [Result= try MeetingwOffset([Offset]+100) otherwise null, Offset=[Offset]+100],

each [Result])

-----------------------------------------

 

Function 2

-----------------------------------------

(Offset as number)=>let

    Source = Json.Document(Web.Contents("https://webexapis.com/v1/" & "meetings"

    &"?hostEmail=AAA"

     &"&max=100&offset="&Number.ToText(Offset),

    [Headers=[Authorization=List.Min(#"Refresh Token (POST)")]])),

    #"Converted to Table" = Table.FromRecords({Source}),

    #"Removed Columns" = Table.RemoveColumns(#"Inserted Minutes",{"Custom"})

in

    #"Removed Columns"

-----------------------------------------

 

Thank you for your help in advance.

3 REPLIES 3
ImkeF
Community Champion
Community Champion

Hi @Anonymous ,
not sure I fully understand, but wouldn't you have t make the site dynamic like in the first function?:

 

(Offset as number, hostEmail as text)=>let

    Source = Json.Document(Web.Contents("https://webexapis.com/v1/" & "meetings"

    &"?hostEmail="&(hostEmail)

     &"&max=100&offset="&Number.ToText(Offset),

    [Headers=[Authorization=List.Min(#"Refresh Token (POST)")]])),

    #"Converted to Table" = Table.FromRecords({Source}),

    #"Removed Columns" = Table.RemoveColumns(#"Inserted Minutes",{"Custom"})

in

    #"Removed Columns"

--------------------------------

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

ImkeF
Community Champion
Community Champion

Hi @Anonymous ,
cannot see anything wrong with your function.
Did you try the URL that is created through another tool like Postman or Power Automate to see if the correct results are returned?
Might be actually an isse on how the URL is structured.

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Anonymous
Not applicable

Hi @ImkeF

Both functions work separately, but I need to combine them into a single function so I can apply the function against the site table and have it paginate. 

I would be grateful for your advice.

Thanks, Bianca

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.