Forum Discussion
how to push data trough api
- 6 years ago
Hi Anonymous ,
Ok the document is out-dated. Please follow my instruction as below
1. Update the nuget package manager for the Microsoft.IdentityModel.Clients.ActiveDirectory
Install-Package Microsoft.IdentityModel.Clients.ActiveDirectory -Version 4.5.1.02. update your code like below
AuthenticationContext authContext = new AuthenticationContext(authorityUri); //update with your master account email and password var userCreds = new UserPasswordCredential("[email protected]", "myEasyToCrackPassword"); var userAuthnResult = authContext.AcquireTokenAsync(resourceUri, clientID, userCreds).Result; string token=userAuthnResult.AccessToken;You don't need the redirect url at all.
ResourceUri and authorityurl remains same as
string resourceUri = "https://analysis.windows.net/powerbi/api"; //OAuth2 authority Uri string authorityUri = "https://login.microsoftonline.com/common/";
Hi Jayendran ,
Thanks for you answer, for the resourceUri, I shloud keep the follownig line?
string resourceUri = "https://analysis.windows.net/powerbi/api";
I had the window for loggin/password but when I click on the button to connect, I have the following message
Hi Anonymous ,
Ok the document is out-dated. Please follow my instruction as below
1. Update the nuget package manager for the Microsoft.IdentityModel.Clients.ActiveDirectory
Install-Package Microsoft.IdentityModel.Clients.ActiveDirectory -Version 4.5.1.0
2. update your code like below
AuthenticationContext authContext = new AuthenticationContext(authorityUri);
//update with your master account email and password
var userCreds = new UserPasswordCredential("[email protected]", "myEasyToCrackPassword");
var userAuthnResult = authContext.AcquireTokenAsync(resourceUri, clientID, userCreds).Result;
string token=userAuthnResult.AccessToken;
You don't need the redirect url at all.
ResourceUri and authorityurl remains same as
string resourceUri = "https://analysis.windows.net/powerbi/api";
//OAuth2 authority Uri
string authorityUri = "https://login.microsoftonline.com/common/";- Anonymous6 years agoNot applicable
Jayendran Thank you very much!
It works, I have the token et I create the dataset but it doesn't work when I add rows as in this step:
https://docs.microsoft.com/en-us/power-bi/developer/walkthrough-push-data-add-rows
- Anonymous6 years agoNot applicable
I found the answer here:
- Jayendran6 years agoSolution Sage
Hi Anonymous ,
Glad that you solved your issue and also provided the link. I hope it will help sombody in the future too 😊
Thanks