Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hello everyone,
I'm facing issues with the oauth2 token request in Power Query. See the query below:
let
AccessToken = Json.Document(Web.Contents("xxx",
[
Headers=[Accept="application/json", #"Content-Type"="application/x-www-form-urlencoded"],
Content=Text.ToBinary(
"grant_type=client_credentials&
client_id=xxx&
client_secret=xxx&
scope=xxx"
)
]))
in
AccessToken
I'm facing the error below:
In Postman, I succeeded to get a response with token.
Could anyone provide any help?
Hi @jordy233 ,
Please review the following links which has the similar problem with yours, hope they can help you resolve the problem.
(400) Bad Request using Web.Contents to connect to REST API via Oauth2
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.
PowerBI DataSource.Error: Web.Contents failed to get contents (400): Bad request
In addition, you can refer the following links to get the token.
Getting Authentication Access Tokens for Microsoft APIs
Accessing API with Oauth2 using M language in Power BI
Best Regards
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 |
| User | Count |
|---|---|
| 11 | |
| 6 | |
| 4 | |
| 4 | |
| 3 |