Forum Discussion

shuaho's avatar
shuaho
Frequent Visitor
7 years ago
Solved

dataset created from data pulled from restful service can not refresh

I am using the dataset created using M language to pull data from a restful service.  When publish to app.powerbi.com,  the refresh failed.  And the reports only include data before published.  

How do I setup to refresh the report?

 

Thanks 

 

Below is the script to get data:

 

let
Query2 = let

url="http://api.AAAAA.com/api/1.0/authentication",
body = "{
""userName"":""AAAA"", 
""password"":""BBBBBB"" 
}",

jsonResult = Json.Document(Web.Contents(url,[Headers =[#"Content-Type"="application/json"],Content = Text.ToBinary(body) , Timeout=#duration(0,2,0,0)])), 
token = jsonResult[accessToken],
location_url = "http://api-test.AAAAA.com/api/1.0/sites",
sites = Json.Document(Web.Contents(location_url,[Headers =[Accept="application/json", Authorization=token]]))
in
sites[result],  

 

refresh error message

 

Data source error:Scheduled refresh has been disabled because at least one data source is missing credentials. For refresh to succeed, you must provide credentials for all data sources. Please enter the data source credentials on the dataset settings page and then reactivate scheduled refresh.
Cluster URI:WABI-CANADA-CENTRAL-redirect.analysis.windows.net
Activity ID:beb6f600-7d62-4776-a3b0-a85c2667ce60
Request ID:e3b456cd-296a-22d5-ea94-8eaa815f759e
Time:2018-10-26 02:09:01Z
  • Anonymous's avatar
    Anonymous
    7 years ago

    Hi shuaho,

     

    I'd like to suggest you move 'get token' method to original query instead use sub query, current power bi service seems not support custom function.

     

    let
    	url="http://api.AAAAA.com/api/1.0/authentication",
    	body = "[{""userName"":""AAAA"", ""password"":""BBBBBB""}]",
    	jsonResult = Json.Document(Web.Contents(url,[Headers =[#"Content-Type"="application/json"],Content = Text.ToBinary(body) , Timeout=#duration(0,2,0,0)])), 
    	token = jsonResult[accessToken],
    	location_url = "http://api-test.AAAAA.com/api/1.0/sites",
    	Source= Json.Document(Web.Contents(location_url,[Headers =[Accept="application/json", Authorization=token]]))[result]
    in
    	Source

     

    BTW, have you configure datasource credentials with 'anonymous' mode on power bi service side?

     

    Regards,

    Xiaoxin Sheng

4 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi shuaho,

     

    I'd like to suggest you move 'get token' method to original query instead use sub query, current power bi service seems not support custom function.

     

    let
    	url="http://api.AAAAA.com/api/1.0/authentication",
    	body = "[{""userName"":""AAAA"", ""password"":""BBBBBB""}]",
    	jsonResult = Json.Document(Web.Contents(url,[Headers =[#"Content-Type"="application/json"],Content = Text.ToBinary(body) , Timeout=#duration(0,2,0,0)])), 
    	token = jsonResult[accessToken],
    	location_url = "http://api-test.AAAAA.com/api/1.0/sites",
    	Source= Json.Document(Web.Contents(location_url,[Headers =[Accept="application/json", Authorization=token]]))[result]
    in
    	Source

     

    BTW, have you configure datasource credentials with 'anonymous' mode on power bi service side?

     

    Regards,

    Xiaoxin Sheng

    • shuaho's avatar
      shuaho
      Frequent Visitor

      Anonymous   thanks for answering!

       

      I need to set a 'GET' request reachable endpoint to make the refresh work. 

      But you answer helped me,  thanks!

      • laciodrom_80's avatar
        laciodrom_80
        Icon for Helper IV rankHelper IV

        shuaho, Anonymous  hi guys,

         

        I'm facing the same problem with two same queries: the first to get the token and the second to get some data. No matter trying to refresh dataset from power bi desktop, but trying to refresh it on power bi service I've got the same credentials issue, also configuring datasource credentials with 'anonymous' mode. :smileyfrustrated:

         

        Could you please give me a suggestion about this?

         

        Thanks a lot in advance