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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
PowerSync
New Member

Shopify API Pagination - Power BI

Hi,

I'm trying to connect a Shopify store to Power BI but I'm having difficulties with pagination after reviewing every single forum and documentation.

this is the M code I made:

 

 

let
    // Base URL for the initial request
    BaseUrl = "https://{my_store_name}.myshopify.com/admin/api/2024-04/products.json?limit=250",
    
    // Function to recursively fetch all pages of data
    GetAllPages = (url as text) as table =>
    let
        // Perform the web request
        Response = Web.Contents(url, [Headers=[#"X-Shopify-Access-Token"={AccessTokenParameter}]]),
        Source = Json.Document(Response),
        // Extract the products data
        Data = Source[products],
        // Convert the data list to a table
        CurrentPage = if List.IsEmpty(Data) then Table.FromRecords({}) else Table.FromList(Data, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
        // Retrieve the response headers
        ResponseHeaders = Value.Metadata(Response)[Headers],
        // Check for the presence of a next page link in the headers
        LinkHeader = if Record.HasFields(ResponseHeaders, "Link") then ResponseHeaders[Link] else null,
        // Parse the next page link if it exists
        NextLink = if LinkHeader <> null and Text.Contains(LinkHeader, "rel="&"\""next\""") then Text.BetweenDelimiters(LinkHeader, "<", ">") else null,
        // Recursively fetch the next page if a next link is present
        NextPage = if NextLink <> null then GetAllPages(NextLink) else null,
        // Combine the current page data with the next page data
        Output = if NextPage <> null then Table.Combine({CurrentPage, NextPage}) else CurrentPage
    in
        Output,

    // Initial call to the function with the base URL
    Result = GetAllPages(BaseUrl)
in
    Result

 

 

 

I would greatly appreciate the help of community members to understand what is wrong with PAGINATION.

 

thank you

1 REPLY 1
lbendlin
Super User
Super User

https://learn.microsoft.com/en-us/power-query/handling-paging

 

Also, please use Web.Contents correctly.  Use RelativePath and Query parameters. https://learn.microsoft.com/en-us/powerquery-m/web-contents#example-1

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.