Forum Discussion
How to pull data from Web API into PowerBI using Authorization header
- Anonymous6 years ago
So I've found the solution and it was due to a PowerBI expecting and requiring a content in the API request. Not sure why this is required by PowerBI but this is the magic step I was missing. Full simplified example below:
let accesstoken = "token " & #"API", url=Text.Combine({#"URL", "/api/tokens/authenticate"}), Source = Json.Document( Web.Contents(url, [ Headers = [#"Authorization" = accesstoken], Content = Text.ToBinary("grant_type=client_credentials") ])) in SourceThe Content of "grant_type=client_credentials" seems to be required for PowerBI when handling the authentication yourself in the query.
I have a similar issue, on the desktop side, all works, I have a function to call the token one time, and then use that token in all the subsequent calls, in Dektop irt refreshes fine. When I publish that, the services asks me to Edit Credentials to the soruces, what credentials? all is within the model, refresh token, token, client id, all that is within the PBI model, how do I configre in the service so it refreshes?