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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Gjakova
Post Patron
Post Patron

Refreshable token API + Credential Errors when trying to refresh in PBI Service

Hi there, I'm facing the following issue. The following script refreshes my dashboard in PBI Desktop (and even in PBI Service), but it gives me a credential error and says that it can't retrieve the latest data:

 

It says: "Failed to update data source credentials: The credentials provided for the Web source are invalid."

 

It doesn't matter which privacy level I select, it keeps telling me that it is invalid. I spent quite some hours to fix this and search for a solution but I keep hitting a wall.

 

I don't have an account or something else, just an API key which is enough to retrieve the data. This is my script (anonymous of course):

 

 

let
  // retrieving the token:
  url = "https://company.firmname.com/auth/login/firmnamepowerbi/apiKey?apiKey=7890abcd",
  body = "{ ""client_id"": ""****"",  ""client_secret"": ""****"", ""grant_type"": ""****"", ""audience"":""****""}",
  tokenSubStep = Json.Document(Web.Contents(url,[Headers = [#"Content-Type"="application/json"], Content = Text.ToBinary(body) ] )),
  tokenResponse = tokenSubStep [token],
  // add token in the URL:
  Source = Json.Document(Web.Contents("https://company.firmname.com/list/projects", [Headers=[Authorization="Bearer "&tokenResponse]])),
  items = Source[items],
  #"Converted to Table" = Table.FromList(items, Splitter.SplitByNothing(), null, null, ExtraValues.Error)
in
  #"Converted to Table"

 

I don't know if the body part is needed, but I found above template online, and even when I just filled it likes this (****) it worked in PBI desktop. Tried removing that line, but then it did not work.

 

Just for clarity, the only thing that I have/need it he API key: 7890abcd. When I enter the url (2nd line) in Postman, it also gives me results, but it is just the credential part that gives me issues. Normally with API's I also get an account and password etc, but now I just have an API key so I don't know how to adjust my script.

 

I hope someone can help me out! Thanks in advance!

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

"I don't know if the body part is needed, but I found above template online, and even when I just filled it likes this (****) it worked in PBI desktop. Tried removing that line, but then it did not work."

 

That part is needed to convert the web call from GET to POST even if you don't have a meaningful payload.

View solution in original post

3 REPLIES 3
lbendlin
Super User
Super User

"I don't know if the body part is needed, but I found above template online, and even when I just filled it likes this (****) it worked in PBI desktop. Tried removing that line, but then it did not work."

 

That part is needed to convert the web call from GET to POST even if you don't have a meaningful payload.

So you can insert whatever you want and it will still work?

in this particular case, yes.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Feb2025 NL Carousel

Fabric Community Update - February 2025

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

Top Solution Authors
Top Kudoed Authors