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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Markzolotoy
Impactful Individual
Impactful Individual

Paginated report - export to file in C#

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

2 REPLIES 2
v-kkf-msft
Community Support
Community Support

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

v-kkf-msft
Community Support
Community Support

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();
            
            
        }


    }
}

vkkfmsft_0-1645598288756.png

 

 

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.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors