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
Found some discussion but was all on Wepapp.
In a simple console app I would like to conect the PBI API, but i'm keep running into this error.
UriFormatException: Invalid URI: The hostname could not be parsed.
This is the very basic code ...
private static string clientId = "Key-received-by-creating-the-app-with-pbi-portal";
private static string ResourceUrl = @"https://analysis.windows.net/powerbi/api";
private static string AuthorityUrl = @"https://login.windows.net/common/oauth2/authorize";
private static string ApiUrl = @"https://api.powerbi.com/";
private static string token;
private static PowerBIClient pbiClient;
static void Main(string[] args)
{
Console.WriteLine("Connecting ...");
pbiClient = GetToken();
Console.WriteLine("Conneced.");
Console.ReadKey();
}
private static PowerBIClient GetToken()
{
var credential = new UserPasswordCredential("a.user@somedomain.be", "xyz");
var authenticationContext = new AuthenticationContext(AuthorityUrl, false);
var authenticationResult = authenticationContext.AcquireTokenAsync(ResourceUrl, clientId, credential).Result;
var tokenCredentials = new TokenCredentials(authenticationResult.AccessToken, "Bearer");
var client = new PowerBIClient(new Uri(ApiUrl), tokenCredentials);
return client;
}If somebody could give me a hand, i'm not a C# developper, but would like to create a simple program to define py push datasets.
Kind regards, Harry
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 4 | |
| 3 | |
| 2 | |
| 1 | |
| 1 |
| User | Count |
|---|---|
| 4 | |
| 4 | |
| 4 | |
| 3 | |
| 2 |