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
sgargeta
New Member

Web.Contents is not working

Hi,

 

My report calls a webapi and authenticates using odata with bearer.

 

In the powerbi destop it works and the data is returned, but when it publishes in powerbi on the web I get the error.

 

Here part of the code that works on pbi desktop.

 

 

let
 url = "<URL>",
 GetJson = Web.Contents(url,
     [
         Headers = [#"uuid"="0",
		    #"modelo"="powerbi",
		    #"so"="powerbi",
	            #"versao"="powerbi",
		    #"tokenfirebase"="powerbi",
                    #"Content-Type"="application/x-www-form-urlencoded;charset=UTF-8"],
         RelativePath="/<partial url>/token",
         Content = Text.ToBinary("grant_type=password&username=USER&password=PASSWORD"),
         Timeout = #duration(0,0,5,0)
     ]
 ),
FormatAsJson = Json.Document(GetJson),
AccessToken = FormatAsJson[access_token],

 

In pbi online it generates the error

 

"Your data source can not be updated because the credentials are invalid. Please update your credentials and try again."

 

Authentication is anonymous.

 

I've tried all kinds of authentication none works

 

Please I need help

 

1 REPLY 1
v-jiascu-msft
Employee
Employee

Hi @sgargeta,

 

Is the web content public available? Maybe you can get it from your local network, while the Power BI Service can't get it from the public Internet. 

Secondly, the authentication is anonymous, but you hardcode the username and password. Right? If it's possible using Power BI to do this. 

 

Web.Contents is not working.JPG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Thirdly, did you check the settings of dataset in the Power BI Servcie?Web.Contents is not working2.JPG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

If it's possible for you to post the name of the API you are using, I could do some tests.

 

Best regards!

Dale

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

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