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

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

Reply
FelipMark
Helper II
Helper II

How to make pagination using cursor api facebok

Hello, I'm querying a facebook API to get data from ad campaigns, but the API has a limit and can't load all the data in a single query, so I decided to limit it to 500 lines and I want to loop to make a request to every 500 pages until you run out of data.

I tried to make a loop using the offset parameter but it doesn't work with the request I'm making... I realized that when I open the .Json the link to the next page is returned.

FelipMark_0-1693971116726.png


How do I create a query that will join all the pages in a single table?

Here's the query I'm using:

 

let
    UrlBase = "https://graph.facebook.com/v17.0/act_636965624958777/insights",
    Cabecalho = [Authorization = "Bearer [TOKEN]"],
    Parametros = [
        fields = "ad_id,campaign_name,ad_name,adset_name,spend",
        time_increment = "1",
        level = "ad",
        limit = "500"
    ],
    Consulta = Web.Contents(
        UrlBase,
        [
            Headers = Cabecalho,
            Query = Parametros
        ]
    ),
    Data = Json.Document(Consulta)
in
    Data

 

 

0 REPLIES 0

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.

Top Kudoed Authors