Forum Discussion

Lina_B's avatar
Lina_B
Regular Visitor
5 years ago

Issue with pagination for airtable (no records)

Hello,

 

I tried to apply the pagination formula to obtain more than 100 records from airtable in the power query. Unfortunately, the pagination does not work and I have no more records (I have the names of all the columns but no records (1 record = null). I tried several times with the different formulas found in the forum, but it finds no records. 

 

The formula I used in the Advanced Editor, using my Table, App and Key ID, is as follows: 

 

 

 

let
    Pagination = List.Skip(List.Generate( () => [Last_Key = "init", Counter=0], // Start Value
           each  [Last_Key] <> null, // Condition under which the next execution will happen
           each [ Last_Key = try if [Counter]<1 then "" else [WebCall][Value][offset] otherwise null,// determine the LastKey for the next execution
                       WebCall = try if [Counter]<1 then Json.Document(Web.Contents("https://api.airtable.com/v0/[APP_ID]/[TABLE_ID]", [Headers=[Authorization="Bearer [KEY_ID]"]]))
                        else Json.Document(Web.Contents("https://api.airtable.com/v0/[APP_ID]/[TABLE_ID]?offset="&[WebCall][Value][offset])), // retrieve results per call
                   Counter = [Counter]+1// internal counter
                      ],
           each [WebCall]
    ),1),
 
    #"Converted to Table" = Table.FromList(Pagination, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
in
#"Converted to Table"
 
 
 
Thank you for your help!

1 Reply

  • hi Lina_B 

    I'm a little unclear on the results you are getting.  You say you have no more records, and you have the names of all the columns but no records, yet you say you have 1 record = null?

    Maybe if you shared an image of your actual results it would be clearer to me.

    Using your code below to connect to my own Airtable account I successfully retrieve data.

    Have you tried confirming that your API call below is actually returning data?  You can issue a request directly in your browser like this

     

     

    https://api.airtable.com/v0/BASE_ID/TABLE_ID?api_key=keyXXXXXXXXXX

     

     

     Phil


    If I answered your question please mark my post as the solution.
    If my answer helped solve your problem, give it a kudos by clicking on the Thumbs Up.