Forum Discussion
Connecting to API
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.
- Anonymous4 years ago
Anonymous Great, the idea was only to pass the credential in the body and not in header as you were doing earlier.
13 Replies
- ghumarepratik21Regular Visitor
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+with+power+bi&aqs=chrome.0.0i512j0i22i30l3.4737j0j4&sourceid=chrome&ie=UTF-8#kpvalbx=_86cYYpb_GIq75OUP8-ahiA819
Thanks,
Prateek G- AnonymousNot applicable
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.
- AnonymousNot applicable
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 ResultRegards,
Xiaoxin Sheng
- AnonymousNot applicable
Thanks Anonymous for your inputs. Will explore on this.
- AnonymousNot applicable
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.
- AnonymousNot applicable
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
- AnonymousNot applicable
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.
- AnonymousNot applicable
Thank you Anonymous, I will check this and get back.
- vannda21Helper I
Hello Anonymous ,
Does it work for you now?