cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Bond007
Regular Visitor

Power query to connect REST API with basic authentication is always returning 400 Bad response

Hello,

 

I am trying to connect to a REST API from Power BI desktop using following code but it is always returning 400 bad request. However, when I am trying to connect to this API with same data and same header from a generic client like RESTESD chrome extention, it is successful.   In fiddler, I observed one thing that when request is sent from RESTED , it is creating 3 rows in fiddler withh status code 407,407,200 respectively ( only the first row but when I am tryng to connect from PowerBI desktop, I see only 2 rows 407,200. I do not see any 400 in Fiddler though. 

 

let
authKey = "Basic " & Binary.ToText(Text.ToBinary("Client-id:ClientSecret"),0),
url="https://urlxxxxxx/oauth/token",
Source = Web.Contents(url,
[
Headers=[Authorization="authKey", #"Content-Type"="application/x-www-form-urlencoded"],
Content =Text.ToBinary("grant_type=client_credentials")
]
)

in
Source

 ....

 

.......

 

 

1 ACCEPTED SOLUTION
Bond007
Regular Visitor

Problem is authKey was in quotes ..... Sometimes very simple mistake take lot of time to solve if error description is not helpful...

View solution in original post

1 REPLY 1
Bond007
Regular Visitor

Problem is authKey was in quotes ..... Sometimes very simple mistake take lot of time to solve if error description is not helpful...

View solution in original post

Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!