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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
zibster
Helper III
Helper III

Web.Connect

HI,

 

Would anyone know how to make the refresh work in Power BI app for the code below? It works perfect in desktop App.

 

 

Thanks Z

 

let
token = "-------------------------------------",

    baseUrl = "https://www.ncdc.noaa.gov/cdo-web/api/v2/",

    endpoint = "data",

    stationid1 = ":US1COLP0022",

    datasetid = "GHCND",

    StartDate = Date.ToText(Date.AddDays(DateTime.Date(DateTime.LocalNow()),-366),"YYYY-MM-DD"),

    EndDate = Date.ToText(Date.AddDays(DateTime.Date(DateTime.LocalNow()),-360),"YYYY-MM-DD"),

    url = Text.Combine({baseUrl,endpoint,"?stationid=",datasetid,stationid1,"&datasetid=",datasetid,"&startdate=",StartDate,"&enddate=",EndDate}),

    limit = 1000, // Defaults to 25, maximum is 1000.

    request = Web.Contents(

        url,

        [Headers = [token = token],

            Query = [

                limit = Text.From(limit)

            ]

        ]

    ),

    requestData = Json.Document(request),

    metadata = requestData[metadata],

    results = requestData[results],

    #"Converted to Table" = Table.FromList(results, Splitter.SplitByNothing(), null, null, ExtraValues.Error),

    #"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"date", "datatype", "station", "attributes", "value"}, {"Column1.date", "Column1.datatype", "Column1.station", "Column1.attributes", "Column1.value"})

in

    #"Expanded Column1"

2 REPLIES 2
v-lili6-msft
Community Support
Community Support

hi @zibster 

After you publish the report to Power BI service, please go to the Dataset Settings page. If the Power Query to get data contains web.page function, you will need a gateway for the dataset. You can configure a on-premise data gateway and create a web data source with the same URL used in desktop. Then set the dataset use this data gateway. 

https://docs.microsoft.com/en-us/power-bi/service-gateway-onprem

7.JPG

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi,

 

Unfortunately my Co. does not allow personal gateway, i was hoping for some other solution.

 

Thanks

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.