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.
I am able to get through export to file Online. I am sure it would work the same in Postman. I am assuming it also should work from C#. However, since I am not a C# developer I am looking for an example. I am ok to hard code as much as possible for now. Please provide one if you have. My main concert is how to provide my credentials. Currently I am doing everything manually - providing my work account and selecting an appropriate group if that is what I am selecting after my work credentials.
Thanks
Hi @Markzolotoy ,
Has your problem been solved? If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
Hi @Markzolotoy ,
To get access token, please try the following code.
using System;
using System.Collections.Generic;
using System.Net.Http;
namespace AzureAAD
{
class Program
{
private static string token = string.Empty;
static void Main(string[] args)
{
var client = new HttpClient();
var uri = "https://login.microsoftonline.com/ixxxh.onmicrosoft.com/oauth2/token?api-version=1.0";
var pairs = new List<KeyValuePair<string, string>>
{
new KeyValuePair<string, string>("resource", "https://analysis.windows.net/powerbi/api"),
new KeyValuePair<string, string>("client_id", "xxxxxxx"),
new KeyValuePair<string, string>("grant_type", "client_credentials"),
new KeyValuePair<string, string>("client_secret", "xxxxxxx"),
new KeyValuePair<string, string>("scope", "openid")
};
var content = new FormUrlEncodedContent(pairs);
var response = client.PostAsync(uri, content).Result;
string result = string.Empty;
if (response.IsSuccessStatusCode)
{
result = response.Content.ReadAsStringAsync().Result;
}
Console.WriteLine(result);
Console.ReadLine();
}
}
}
Or please refer to these documents:
How to get Azure Access Token using C#
Getting Started with the Power BI API – Querying the Power BI REST API Directly (with C#)
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.