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
Anonymous
Not applicable

Query contains unsupported function. Function name: Web.Contents

Hi Everyone. 

 I am trying to get data from a  REST Oauth API from long time. I have succesfully configured the API in Power Bi desktop. I am getting the Oauth token and then getting the data, But when i publish the report to Power Bi Server, A data set is generated for the report automatically. When i am trying to Refresh the data. I am getting an error.

Guys I am really tired of this issue from long time.

Issue is.

 

"You can't schedule refresh for this dataset because the following data sources currently don't support refresh:

  • Data source for Query1

Discover Data Sources

Query contains unsupported function. Function name: Web.Contents "

 

The M Query  is perfectly working on Power Bi desktop and refresh is also working but not working on the Server.

 

 

let
    token_url = "https://api.example.com/v2/oauth/token",    

    //This is for Dynamic Data filter of last day which i have used in api base url
    endDate = Date.From( DateTime.LocalNow() ),
    startDate = Date.AddDays( endDate , -2 ),
    startDateText = Date.ToText( startDate, "yyyy-MM-ddT01" ),
    endDateText = Date.ToText( endDate, "yyyy-MM-ddT23" ),
    api_base_url = "https://openapi.example.com/api/reporting-details/v2/prod/views/PurchaseOrders?realm=myrealm&filters=%7B%22createdDateFrom%22%3A%22"& startDateText &"%3A00%3A00Z%22%2C%22createdDateTo%22%3A%22"&endDateText&"%3A59%3A59Z%22%7D",
    qry_str = "?myparameter",

// Getting Oauth Access Token
   body="grant_type=openapi_2lo",
   Source  = Json.Document(Web.Contents(token_url,
   [ 
     Headers = [
       #"Content-Type"="application/x-www-form-urlencoded",
        #"Authorization"="Basic Tyuek938nrkdtoo439nrhyeojgwpddam2ie6gsd8wokf08ugdiwjjtAOp73hwusb"
       ],
     Content=Text.ToBinary(body)
   ])),
    token = Source[access_token],
// Oauth Token Section Ended


    // Getting Data From Api 
    data= Json.Document(Web.Contents(api_base_url&qry_str,
   [ 
     Headers = [
                #"Authorization"="Bearer "&token,
                #"Content-Type"="application/json",
                #"apiKey"="845RCEJTL63884jlkjaellT77kwnn"
                ]
     
   ])),
    Records = data[Records],
    #"Converted to Table" = Table.FromList(Records, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    //Alot of lines removed , Conversion to tabular form.
    in
    #"Renamed Columns"

 

 

 

Thanks Everyone.

4 REPLIES 4
v-alq-msft
Community Support
Community Support

Hi, @Anonymous 

 

You cannot schedule refresh for this dataset because it gets data from sources that currently don’t support refresh.

This happens when the data source you used, within Power BI Desktop, isn’t supported for refresh. 

 

A dynamic data source is a data source in which some or all of the information required to connect cannot be determined until Power Query runs its query, because the data is generated in code or returned from another data source. 

 

In most cases, Power BI datasets that use dynamic data sources cannot be refreshed in the Power BI service. There are a few exceptions in which dynamic data sources can be refreshed in the Power BI service, such as when using the RelativePath and Query options with the Web.Contents M function. Queries that reference Power Query parameters can also be refreshed.

 

To determine whether your dynamic data source can be refreshed, open the Data Source Settings dialog in Power Query Editor, and then select Data Sources In Current File. In the window that appears, look for the following warning message, as shown in the following image:

d1.png

 

If that warning is present in the Data Source Settings dialog that appears, then a dynamic data source that cannot be refreshed in the Power BI service is present. For further information, you may refer to the following documents.

Troubleshooting unsupported data source for refresh 

Refresh and dynamic data sources 

 

Best Regards

Allan

 

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

Anonymous
Not applicable

Anonymous
Not applicable

Hi @Anonymous .

 

Thank you for your Support. I have tried that post and replaced the url variable with a string. But still I am having the issue.  I cant figure out where exactly the problem is.

 

Thanks

 

 

I was able to resolve it with this solution.

https://stackoverflow.com/questions/53568536/how-to-refresh-report-that-uses-custom-functions-on-pow...

It then stopped showing me the error message and allowed me to check the box to skip the test connection.

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