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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
PowerUser123
Helper II
Helper II

Implementing API Delay Function.InvokeAfter

So I have a couple functions that I'm trying to setup a delay using Function.InvokeAfter. I think I'm doing something wrong as I'm still hitting rate limits, and using Fiddler, I can see that there isn't a delay being implemented.

 

First Function PaginateAPI

 

(endpoint as text) =>
let
    HasContToken = (responseHeaders) as logical => if (Record.HasFields(responseHeaders, {"next_page"})) then 
                true
                else
                false,
    
    Pages = List.Generate(() => 
            GetBase(endpoint, "1"),
            each HasContToken(Value.Metadata(_)),
            each try GetBase(
                        endpoint, 
                        Text.Split(Text.Split(Value.Metadata(_)[next_page], "?page="){1}, "&"){0}
                    ) 
            otherwise null
        ),
    List = List.Combine(Pages),
    Table = Table.FromList(List, Splitter.SplitByNothing(), null, null, ExtraValues.Error)
in
    Table

 

GetBase

let
    Source = (endpoint as text, page as text) =>
let
    url = "https://someapi.com/",
    Source = Json.Document(Web.Contents(url,
    [
        Headers = [
            #"Accept"="application/json",
            #"api-code"="SomeString",
            #"Authorization"="Bearer " & APIKey
        ],
        RelativePath = endpoint,
        Query = [
                    page=page
                ]
    ]
    )),
    next_page = Source[meta][pagination][links][next],
    final = Source[data] meta [ next_page = next_page ]
in
    final
in
    Source

 

I invoke the first Function PaginateAPI as such: 

 

= Function.InvokeAfter(()=>PaginateAPI("sales"), #duration(0,0,0,5))

 

I'm thinking this is all I need to do to create the delay, but it seems like the delay isn't being implemented. Do I also need to add the Function.InvokeAfter somewhere in the functions as well?

1 REPLY 1
V-lianl-msft
Community Support
Community Support

Hi @PowerUser123 ,

 

See if this video can help you:

https://www.youtube.com/watch?v=Eg-025tN-7U 


Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

Check out the August 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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