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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Simon_Evans
Helper I
Helper I

Handling Pagination of JSON

Hi all

 

I have some M Code which works perfectly fine for 1 REST API provider (So I get all the pages perfectly fine in to one list).

 

Looking at another provider and the JSON is slightly different but still contains the Next Page URL. So adjusted my M function to reflect the JSON but now I only get the first page and no further. I know this all works so this has to be something to do with the structure of the JSON or something with the Next Page URL.. 

 

The M code is this:

let
    Source = List.Generate( () => 
  [URL = "/Students/?options=includePhotos%2CincludeGroupIds%2CincludeGroupIdaasIds%2CincludeGroupXIDs%2CincludeLeavers%2CincludeSubsidiary%2CincludeComms&page=1&pageSize=25",

  Result = Json.Document(Web.Contents("https://xporter.groupcall.com/api/v1/School/3281102",[RelativePath=(URL),Headers=[Authorization="********************"]]))],
each [URL] <> null,
  each [
  URL = [Result][__pagination__][NextPage],
  Result = Json.Document(Web.Contents("https://xporter.groupcall.com/api/v1/School/3281102/Students/",[RelativePath=(URL),Headers=[Authorization="********************* "]])) 
  ]

    )
in
    Source

 

The JSON I'm now trying to work with is the below structure:

JSON Structure.PNG

Can anyone shed any light on why this code now won't paginate please?

1 REPLY 1
lbendlin
Super User
Super User

You may want to clean up your RelativePath variable, and separate the Query parameters into their own section.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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