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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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