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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors