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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Morrison
Helper I
Helper I

Refresh Dataset with Dynamic Web Query with API Token

Hello,

I ask you for help because with this set of Dynamic Data I cannot reload the data automatically.

How can I improve the Query to make it possible to schedule the upload?

 

Morrison_0-1659024708227.png

     let

    BaseUrl         =   https://xxx.xxx.com/api/v3/forms/hash/entries.json?,

    CountUrl         = https://xxx.xxx.com/api/v3/forms/hash/entries/count.json?,

    Token           = "xxxx- xxxx - xxxx - xxxx ",

    EntitiesPerPage = 100,

 

    GetJson = (Url) =>

        let

            RawData = Web.Contents(Url), //, Options),

            Json    = Json.Document(RawData)

        in  Json,

 

    GetEntityCount = () =>

        let Url   = CountUrl, //& "$count=true&$top=0",

            Json  = GetJson(Url),

            Count = Json[#"EntryCount"]

        in  Count,

 

    GetPage = (Index) =>

        let Skip  = "&pageStart=" & Text.From(Index * EntitiesPerPage),

            Top   = "&pageSize=" & Text.From(EntitiesPerPage),

            Url   = BaseUrl & Skip & Top,

            Json  = GetJson(Url),

            //Value = Json

            Value = Json[#"Entries"]

        in  Value,

 

    EntityCount = List.Max({ EntitiesPerPage, Number.FromText(GetEntityCount()) }),

    PageCount   = Number.RoundUp(EntityCount / EntitiesPerPage),

    PageIndices = { 0 .. PageCount - 1 },

    Pages       = List.Transform(PageIndices, each GetPage(_)),

    Entries     = Pages[Entries],

    Entities    = List.Union(Pages),

    Table       = Table.FromList(Entities, Splitter.SplitByNothing(), null, null, ExtraValues.Error),

    #"Tabella Column1 espansa" = Table.ExpandRecordColumn(Table, "Column1", {"EntryId", "Field1", "Field2", "Field36", "Field58", "Field39", "Field57", "Field34", "Field42", "Field12", "Field43", "Field13", "Field50", "Field60", "Field24", "Field63", "Field51", "Field52", "Field65", "Field53", "Field280", "Field483", "Field381", "DateCreated", "CreatedBy", "DateUpdated", "UpdatedBy"}, {"EntryId", "Field1", "Field2", "Field36", "Field58", "Field39", "Field57", "Field34", "Field42", "Field12", "Field43", "Field13", "Field50", "Field60", "Field24", "Field63", "Field51", "Field52", "Field65", "Field53", "Field280", "Field483", "Field381", "DateCreated", "CreatedBy", "DateUpdated", "UpdatedBy"}),

    //#"Rinominate colonne" = Table.RenameColumns(#"Tabella Column1 espansa",{{"EntryId", "Entry ID"}, {"Field1", "Nome"}})

    #"Renamed Columns"      = Table.RenameColumns(#"Tabella Column1 espansa",Table.ToRows(#"Nome Query"),MissingField.Ignore),

    #"Rinominate colonne" = Table.RenameColumns(#"Renamed Columns",{{"Field2", "Cognome"}, {"Nome e Cognome", "Nome"}}),

    #"Testo inserito tra i delimitatori" = Table.AddColumn(#"Rinominate colonne", "Seleziona PDV", each Text.BetweenDelimiters([#"Seleziona PDV#(lf)"], "[", "]"), type text),

    #"Modificato tipo" = Table.TransformColumnTypes(#"Testo inserito tra i delimitatori",{{"Date Created", type datetime}}),

    #"Modificato tipo1" = Table.TransformColumnTypes(#"Modificato tipo",{{"Date Created", type date}}),

    #"Aggiunta colonna personalizzata" = Table.AddColumn(#"Modificato tipo1", "CompanyCode", each "TE"),

    #"Query accodata" = Table.Combine({#"Aggiunta colonna personalizzata", #"Nome Query 2", #"Nome Query 3"}),

    #"Filtrate righe" = Table.SelectRows(#"Query accodata", each true)

in

    #"Filtrate righe"

//in

   // #"Rinominate colonne"

 

Thx All

 

1 ACCEPTED SOLUTION
ImkeF
Community Champion
Community Champion

Hi @Morrison ,
this article contains some methods to apply for your case: Chris Webb's BI Blog: Web.Contents(), M Functions And Dataset Refresh Errors In Power BI Chris Webb'...

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

1 REPLY 1
ImkeF
Community Champion
Community Champion

Hi @Morrison ,
this article contains some methods to apply for your case: Chris Webb's BI Blog: Web.Contents(), M Functions And Dataset Refresh Errors In Power BI Chris Webb'...

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

July Power BI Update Carousel

Power BI Monthly Update - July 2026

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

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.

Top Solution Authors