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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Mobleyjk
Frequent Visitor

Paginated List Query Error

Hello,

 

I'm working with the below query to pull in multiple tables of data from our API, but I'm receiving an error with one of my paramaters. I'd appreciate it if someone could point out where I've made a mistake.

 

Error:

Expression.Error: The field 'next' of the record wasn't found.
Details:
result=[List]

 

Query:

let
Source = List.Generate( ()=> [Result = Json.Document(Web.Contents("link.link")), Counter=0, next = Json.Document(Web.Contents("link.link"))[next]],
each [next] <> null,
each [
next = [Result][next],
Result = let
next = [Result][next],
offset = Text.BetweenDelimiters( next, "offset=", "&"),
limit = Text.AfterDelimiter(next, "limit="),
StartWithEmptyTable = Json.Document(Web.Contents("link.link", [Query=[offset=Text.From(offset), limit=Text.From(limit)]]))
in
StartWithEmptyTable,
Counter = [Counter] + 1
]
),
#"Converted to Table" = Table.FromRecords({Source})
in
#"Converted to Table"

1 ACCEPTED SOLUTION
v-karpurapud
Community Support
Community Support

Hi @Mobleyjk 

Thank you for reaching out to the Microsoft Fabric Community Forum.

The error happens because the API response doesn't always include the 'next' field. When you get to the last page of the API pagination, the 'next' link can be null or missing. The current M code tries to access the 'next' field without checking if it exists, which leads to this error: Expression.Error: The field 'next' of the record wasn't found.


Please try the below M Code :

       

let

    InitialUrl = "link.link",



    GetPage = (url as text) as record =>

        let

            Response = Json.Document(Web.Contents(url)),

            NextLink = if Record.HasFields(Response, "next") then Response[next] else null,

            ResultData = Response

        in

            [Result=ResultData, Next=NextLink],



    Pages = List.Generate(

        ()=> GetPage(InitialUrl),

        each [Next] <> null,

        each GetPage([Next]),

        each [Result]

    ),



    #"Converted to Table" = Table.FromList(Pages, Splitter.SplitByNothing(), null, null, ExtraValues.Error)

in

    #"Converted to Table"


I hope this information is helpful. If you have any further questions, please let us know. If this does not helps please share more details so we can assist you further.

Regards,
Karpurapu D,
Microsoft Fabric Community Support Team.

 



View solution in original post

4 REPLIES 4
v-karpurapud
Community Support
Community Support

Hi @Mobleyjk 

We have not yet heard back from you about whether our response addressed your query. If it did not, please share more details so we can assist you more effectively.

 

Thank You.

 

v-karpurapud
Community Support
Community Support

Hi @Mobleyjk 

We haven't received a response to our last message and wanted to follow up to see if you have found a solution. If you still need help, please share more details so we can assist you further.

Thank you.

v-karpurapud
Community Support
Community Support

Hi @Mobleyjk 

I wanted to check if you’ve had a chance to review the information provided. If you have any further questions, please let us know. Has your issue been resolved? If not, please share more details so we can assist you further.

 
Thank You.

v-karpurapud
Community Support
Community Support

Hi @Mobleyjk 

Thank you for reaching out to the Microsoft Fabric Community Forum.

The error happens because the API response doesn't always include the 'next' field. When you get to the last page of the API pagination, the 'next' link can be null or missing. The current M code tries to access the 'next' field without checking if it exists, which leads to this error: Expression.Error: The field 'next' of the record wasn't found.


Please try the below M Code :

       

let

    InitialUrl = "link.link",



    GetPage = (url as text) as record =>

        let

            Response = Json.Document(Web.Contents(url)),

            NextLink = if Record.HasFields(Response, "next") then Response[next] else null,

            ResultData = Response

        in

            [Result=ResultData, Next=NextLink],



    Pages = List.Generate(

        ()=> GetPage(InitialUrl),

        each [Next] <> null,

        each GetPage([Next]),

        each [Result]

    ),



    #"Converted to Table" = Table.FromList(Pages, Splitter.SplitByNothing(), null, null, ExtraValues.Error)

in

    #"Converted to Table"


I hope this information is helpful. If you have any further questions, please let us know. If this does not helps please share more details so we can assist you further.

Regards,
Karpurapu D,
Microsoft Fabric Community Support Team.

 



Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.