Forum Discussion

magnifybi's avatar
magnifybi
Resolver I
5 years ago

Dynamic Web.Contents Power BI Refresh Error

Hey guys,

 

I've been racking my brains for the last week or so trying to get my query converted so I can run a scheduled refresh with my dynamic Web.Contents query.

 

I have read the following solution and understand the logic behing the concept but am really struggling to apply it to my query;

 

https://community.powerbi.com/t5/Service/Dynamic-Web-Contents-Power-BI-Refresh-Error/td-p/714526

 

I have also read all of the associated learning materials and likewise, I get the approach but can't apply it to my use case;

 

Web.Contents(), M Functions And Dataset Refresh Errors In Power BI

Dynamic Web.Contents() and Power BI Refresh Errors

Using The “Skip Test Connection” Option For Power BI Data Sources To Avoid Scheduled Refresh Failure...

 

I would be so grateful if someone could help me figure out how I need to change my below query so I can use this on scheduled refreshes.

 

I have a table of date ranges that I use this query for via an invoked function and it is working away fine, only issue is converting it.

 

Apologies if the formatting of the quotes here are wrong, I couldn't figure out how to quote M Query.

 

(DateRange)=>

let
    Source = Web.Contents("https://api.weworked.com/v1/reports/summary?fromdate="&DateRange&"&projects=all&showzeros=0&taskstatus=all&timestatus=all&users=all", [Headers=[#"x-api-key"="xxxxxxxxxxxxxxxxxx", #"x-ww-user"="[email protected]"]]),
    #"JSON" = Json.Document(Source),
    #"Converted to Table" = Table.FromList(JSON, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"FirstName", "LastName", "UserId", "InternalId", "Rows"}, {"Column1.FirstName", "Column1.LastName", "Column1.UserId", "Column1.InternalId", "Column1.Rows"}),
    #"Expanded Column1.Rows" = Table.ExpandListColumn(#"Expanded Column1", "Column1.Rows"),
    #"Expanded Column1.Rows1" = Table.ExpandRecordColumn(#"Expanded Column1.Rows", "Column1.Rows", {"project", "task", "taskCode", "billable", "invoiceMethodId", "invoiceMethodName", "rate", "hours", "total"}, {"Column1.Rows.project", "Column1.Rows.task", "Column1.Rows.taskCode", "Column1.Rows.billable", "Column1.Rows.invoiceMethodId", "Column1.Rows.invoiceMethodName", "Column1.Rows.rate", "Column1.Rows.hours", "Column1.Rows.total"})
in
    #"Expanded Column1.Rows1"

 

Thanks,

 

Jon 

2 Replies

  • This is what I have tried but there is some issue with the Query part, would really love some help.

     

    (DateRange)=>
    
    let
        Source = Web.Contents("https://api.weworked.com/v1/reports", [Query=[summary?fromdate="&DateRange&"&projects=all&showzeros=0&taskstatus=all&timestatus=all&users=all], Headers=[#"x-api-key"="xxxxxxxxxxxxxxxxxx", #"x-ww-user"="[email protected]"]]),
        #"JSON" = Json.Document(Source),
        #"Converted to Table" = Table.FromList(JSON, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
        #"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"FirstName", "LastName", "UserId", "InternalId", "Rows"}, {"Column1.FirstName", "Column1.LastName", "Column1.UserId", "Column1.InternalId", "Column1.Rows"}),
        #"Expanded Column1.Rows" = Table.ExpandListColumn(#"Expanded Column1", "Column1.Rows"),
        #"Expanded Column1.Rows1" = Table.ExpandRecordColumn(#"Expanded Column1.Rows", "Column1.Rows", {"project", "task", "taskCode", "billable", "invoiceMethodId", "invoiceMethodName", "rate", "hours", "total"}, {"Column1.Rows.project", "Column1.Rows.task", "Column1.Rows.taskCode", "Column1.Rows.billable", "Column1.Rows.invoiceMethodId", "Column1.Rows.invoiceMethodName", "Column1.Rows.rate", "Column1.Rows.hours", "Column1.Rows.total"})
    in
        #"Expanded Column1.Rows1"

     

    • v-kelly-msft's avatar
      v-kelly-msft
      Community Support

      Hi magnifybi ,

       

      What issue have you got?Do you have some notifications such as below:

       

       

      Best Regards,
      Kelly

      Did I answer your question? Mark my post as a solution!