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.
Hi,
I'm having issues connecting to an API using Oauth2 authentifiation, as it generates the error (400) Bad Request.
I tried to download Fiddler, and I'm not really sure how to use it.. Any help here would be much appreciated.
Here's an example from the documentation (Javascript):
var xmlhttprequest = new XMLHttpRequest(); xmlhttprequest.open("POST", "https://demo.fatman.fi/identity/connect/token", false); xmlhttprequest.setRequestHeader("Authorization", "Basic YWIzMWY4NmM0YzE2NGUxZWE3M2EyNGU3NDE1MTM0Yjk6UnlTUFJKamgzaEZnS3dsYVY4Vjh1dTQ 4VQ=="); xmlhttprequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded") xmlhttprequest.send("grant_type=client_credentials&scope=api") xmlhttprequest.responseTex
Here's the M code:
let
apiUrl = "https://demo.fatman.fi/identity/connect/token",
options = [Content =Text.ToBinary("grant_type=client_credentials&scope=api"),
Headers= [
#"Authorization"="Basic xxxxxxxx",
#"Content-Type"="application/x-www-form-urlencoded"]
],
result = Web.Contents(apiUrl, options)
in
result
Thanks!
Solved! Go to Solution.
@joakims,
There is a similar blog providing details about how to connect to REST API via OAuth2 in Power BI, you can following the instructions in this blog to connect to your data source.
If you still get error, you can use Fiddler to track the process following the guide in this video.
Regards,
Lydia
@joakims,
There is a similar blog providing details about how to connect to REST API via OAuth2 in Power BI, you can following the instructions in this blog to connect to your data source.
If you still get error, you can use Fiddler to track the process following the guide in this video.
Regards,
Lydia
I had a little time to revisit the code, and noticed I had left the "<>" marks for the base hashing. I simply removed them, and now it works. Thanks for the help!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.