Forum Discussion
Anonymous
6 years agoNot applicable
How to pull data from Web API into PowerBI using Authorization header
I'm trying to pull data from a web Server in PowerBI. The web server uses Oauth and requires you to first create a bearer token by posting to the Authentication endpoint as shown below: curl --l...
- 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.
Stachu
6 years agoCommunity Champion
have you read this post already? it seems very similar:
I assume you get the error in the Source step, correct? Does it work if you hardcode the url and the manually generated token?