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.
v-lid-msft
Community Support
6 years agoHi Anonymous ,
Does there miss a space between Authorization="token" and accesstoken? We think it should be
Authorization="token " & accesstoken
What is the error shown in Power Query Editor if run the sample query which get the bearer token?
Best regards,