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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

how to create a M query ( Power Query SDK) to Pull all Page Record

Hi ,

 

I would like to connect API using custome connector to pull the all page data in singble table.

API  I able to pull only 100 record. If I would like to pull remain record using paging . What function need to use . ANy guidance please 

 

Below Query give me the URL for pulling the1000 record, How to write the condiation to pull all the page record in single page.

10 REPLIES 10
Anonymous
Not applicable

Hi ,

 

With above code I can fetch 1000 records of data. For " Remdesivir " total record count is "7239" with limit able to fetch 1000 record without any issue.

Same problem, I have with custome connector . My requirement is fetch all the data without any limit. Please help me same.

 

My sample code fetches all records. Note that Power Query by default only shows 1000 preview rows. Click "Close and apply" to get everything.

Anonymous
Not applicable

Thanks for update.

 

Yes, We are able to pull the records. Is there any possible make use of same code in Custome Connector. 
Any advice one same. Requirement is achieve with Custom Connector.

Yes, you can copy that code into the custom connector Section1. Then add the required code for connection test etc. Follow the documentation for custom connector creation.

Anonymous
Not applicable

Hi,

 

Work perfectly . By the time the record pull more than 26k the query get fail.

 

Query1
OLE DB or ODBC error: [DataSource.Error] Web.Contents failed to get contents from 'https://xxxxx/event.json?search=%20&' (400): Bad Request.

 

Please help me.

What's the total number of rows for that query?  Maybe you ran out of data? Maybe they refreshed the data while you were pulling it?

Anonymous
Not applicable

Hi,

 

 When it hit max 26k we are getting the error. That's limit setup for API. 

The link you provided lists a number of good alternatives. Decide on one of them and implement it.

Anonymous
Not applicable

Hi Sir,

 

Please help me how to implement search_after function . I am new to M query . 

lbendlin
Super User
Super User

This particular API doesn't have a nextlink navigator, it uses Limit and Offset (skip). Therefore it is better to use List.Generate. Below is a sample implementation.

 

let
    Search = "remdesivir",
    Limit = 100,
    Rows = Json.Document(Web.Contents("https://api.fda.gov/drug/event.json",[Query = [search = Search]]))[meta][results][total],
    Fetch = List.Generate(()=>0, each _ < Rows, each _ + Limit),
    #"Converted to Table" = Table.FromList(Fetch, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Added Custom" = Table.AddColumn(#"Converted to Table", "Custom", each Json.Document(Web.Contents("https://api.fda.gov/drug/event.json",[Query = [search = Search, limit = Text.From(Limit), skip = Text.From([Column1])]]))[results]),
    #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom")
in
    #"Expanded Custom"

How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done".

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors