Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi experts,
I am trying to connect PowerBI to API. I a doing this for the first time, so not sure how to proceed. Looking for your guidance.
This is the URL I am trying to connect.
https://login.microsoftonline.com/ea80952e-a476-42d4-aaf4-5457852b0f7e/oauth2/token
I have the following details:
1. client_id = 'c*****a'
2. client_secret = 'r********e'
3. resource= 'f********9'
4. grant_type=client_credentials
I am trying to provide the details as
Getting the below error.
Getting the response from Postman.
Please advise.
Thanks.
Solved! Go to Solution.
@Anonymous Great, the idea was only to pass the credential in the body and not in header as you were doing earlier.
Hello @Anonymous ,
Does it work for you now?
@Anonymous that is a great suggestion, I was able to move to the next stage, but encountering a different issue. Is this something to do with the parameters I am passing? Any suggestion on this?
This is the screenshot of parameters I'm passing.
This is the error I am getting
@Anonymous Try to do it from advance editor query and Put the code as below. Power BI is taking your request as a GET request instead of POST request so you need to create it as a post request.
You are passing these values in Headers but these should be passed in the body part.
Thank you @Anonymous, I will check this and get back.
@Anonymous did it work for you?
@Anonymous I had encountered some other issue. So i created it as a function and called the function.
@Anonymous Great, the idea was only to pass the credential in the body and not in header as you were doing earlier.
@Anonymous totally agree, that was a wonderful pointer.. accepting this as a solution. One should not pass credential in the header but should be passed along in the body.
Thank you!
Go to Data source settings, Select the connection from the list to which you are connecting. Click on edit permissions and check it's set to anonymous, if not then set it to anonymous.
Thanks @Anonymous for your inputs. Will explore on this.
Hello,
You will require authentication key for that API to use header. If you have details you can enter and issue will get resolved.
For refrence you can check below link,
https://www.google.com/search?q=connect+api+with+power+bi&rlz=1C1YQLS_enIN975IN975&oq=connect+api+wi...
Thanks,
Prateek G
Thanks @ghumarepratik21. for the response. I have the client_secret which should be the API key, i believe. Anyways, I will check on this line.
Thanks.
HI @Anonymous,
AFAIK, these types of parameters(e.g. client id, secret) will be transformed into a binary string and attached to the httprequest 'content' part instead of directly sending the original string from the httprequest header.
let
url = "https://login.microsoftonline.com/xxxxxxx/oauth2/token",
GetJson =
Web.Contents(
url,
[
Headers = [
Accept = "application/json",
ContentType = "application/x-www-form-urlencoded"
],
Content =
Text.ToBinary(
"grant_type=client_credentials&
client_id=xxxxxxx&
client_secret=xxxxxxx&
scope=xxxxxx"
)
]
),
token = Json.Document(GetJson)[access_token],
Result =
Web.Contents(
"https://xxxxx.xxx.com",
[
Headers = [
#"Content-Type" = "application/json",
Authorization = "Bearer " + token,
RelativePath = "/xxxxx/xxxxx"
]
]
)
in
Result
Regards,
Xiaoxin Sheng
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
6 | |
6 | |
3 | |
2 | |
2 |
User | Count |
---|---|
6 | |
5 | |
4 | |
4 | |
3 |