Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
Anonymous
Not applicable

how to push data trough api

Hello,

 

I'm following this tutorial:
https://docs.microsoft.com/fr-fr/power-bi/developer/walkthrough-push-data

I choosed a native application type in the first step, what should I use for the different uri in the second step? in the native mode, you have only the clientID
https://docs.microsoft.com/fr-fr/power-bi/developer/walkthrough-push-data-get-token

//RedirectUri you used when you register your app.
          
//For a client app, a redirect uri gives Azure AD more details on the application that it will authenticate.
          
// You can use this redirect uri for your client app
          
string redirectUri = "https://login.live.com/oauth20_desktop.srf";

          
//Resource Uri for Power BI API
          
string resourceUri = "https://analysis.windows.net/powerbi/api";

          
//OAuth2 authority Uri
          
string authorityUri = "https://login.microsoftonline.net/common/";

Thanks for your answer

 

1 ACCEPTED SOLUTION

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("UserName@MyTenent.onMicrosoft.com", "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/";

View solution in original post

10 REPLIES 10
Jayendran
Solution Sage
Solution Sage

Hi @Anonymous ,

 

The Redirect url become valid only for the Web app type registration. Since you used native you can use the one which provided in the code itself

 

string redirectUri = "https://login.live.com/oauth20_desktop.srf";

 

Anonymous
Not applicable

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 messageloggin.PNG

 

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("UserName@MyTenent.onMicrosoft.com", "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/";
Anonymous
Not 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


addRows.PNG

 

 

 

 

Anonymous
Not applicable

Hi @Anonymous ,

 

Glad that you solved your issue and also provided the link. I hope it will help sombody in the future too 😊

 

Thanks 

Anonymous
Not applicable

I try to delete the rows I created, but I have a timeout... Is it only possible to delete the dataset? not rows it contains? thanks

 

delete.PNG

Anonymous
Not applicable

Hello!

To go further, I would like to refresh my data through API:
The first time, I add rows in the dataset I created, as explain before.

Once done, I would like to empty (or delete) the dataset  to send new data

@Jayendran, if you can help me, thanks in advance 🙂

Hi @Anonymous ,

 

Could you please check whether the below conditions

 

Capture1.JPG

 

 

Also I couldn't able to read the error properly as the screenshot not in english

Anonymous
Not applicable

Hi @Jayendran ,

 

It works with the deleteRowsInGroup; it seems a workspace is necessary...

 

thanks again

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.