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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
mihirsp1988
Frequent Visitor

Power BI Embedded API - Updating a specific table in dataset

Hello,

 

I am trying to use PBI API to refresh a specific table in dataset rather than full dataset. I've used following code to refresh only table1 in dataset. But it seems like refreshing all tables. 

 

 

var parameters = new Dictionary<string, string>
            {
                { "table", "Table1" },
                { "refreshType", "Full" }
            };
            
            HttpClient client = new HttpClient();
            client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", accessToken);
            try
            {
                var test = await client.PostAsJsonAsync($"https://api.powerbi.com/v1.0/myorg/groups/{groupid}/datasets/{datasetid}/refreshes",
                new StringContent(JsonConvert.SerializeObject(parameters), Encoding.UTF8, "application/json"));
            }
            catch (System.Exception)
            {

                throw;
            }

 

 

Where as if I use XMLA endpoint - I can refresh only one single table.

 

Can you please suggest what am I doing wrong here? Also, what is the best way to see it's refresing all tables as I am going through only time it takes to refresh dataset? Wiht single table it take 10 seconds where as whole dataset takes longer and it's consistent accros Dev, Test and Prod environemnt.  

1 ACCEPTED SOLUTION

I tried this but it still did not work.

 

After looking into details I think the issue is around how I code my request body in JSON. Beacause when I used following code it started working and I can see Enhanced API as request type in PBI service.

Following the final code I used:

var body = @"{
                " + "\n" +
                @"    ""type"": ""Full"",
                " + "\n" +
                @"    ""commitMode"": ""transactional"",
                " + "\n" +
                @"    ""maxParallelism"": 2,
                " + "\n" +
                @"    ""retryCount"": 2,
                " + "\n" +
                @"    ""objects"": [
                " + "\n" +
                @"        {
                " + "\n" +
                @"            ""table"": ""TableName""
                " + "\n" +
                @"            
                " + "\n" +
                @"        }
                " + "\n" +
                @"    ]
                " + "\n" +
                @"}";

            HttpClient client = new HttpClient();
            client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", aadService.GetAccessToken());
            try
            {
                var test = await client.PostAsync($"https://api.powerbi.com/v1.0/myorg/groups/{groupid}/datasets/{datasetId}/refreshes",
                                   new StringContent(body, Encoding.UTF8, "application/json"));
            }
            catch (System.Exception)
            {
                throw;
            }

 

Thanks Ibendlin for your support.

View solution in original post

4 REPLIES 4
mihirsp1988
Frequent Visitor

Thanks Ibendlin. I've also tried that but whenever I try it from Enhanced refresh it works fine but it does not work from my code. 

The new code I used is as below:

var accessToken = aadService.GetAccessToken();
            //var parameters = new Dictionary<string, string>
            //{
            //    { "table", "{tablename}" },
            //    { "refreshType", "Full" }
            //};
            string jsonText = "{\r\n  \"type\": \"full\",\r\n  \"commitMode\": \"transactional\",\r\n  \"objects\": [\r\n      {\r\n        \"database\": \"{Databasename}\",\r\n        \"table\": \"{tableName}\"\r\n      }\r\n    ],\r\n  \"applyRefreshPolicy\": \"false\"\r\n}";
            HttpClient client = new HttpClient();
            client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", accessToken);
            try
            {
                var test = await client.PostAsJsonAsync($"https://api.powerbi.com/v1.0/myorg/groups/{groupId}/datasets/{datasetId}/refreshes",
                //new StringContent(JsonConvert.SerializeObject(parameters), Encoding.UTF8, "application/json")
                jsonText);
            }
            catch (System.Exception)
            {

                throw;
            }

Is it something wrong with my code?

 

Thanks,

Mihir

 

Applyrefreshpolicy = false will force a full refresh of all dependent partitions.

I tried this but it still did not work.

 

After looking into details I think the issue is around how I code my request body in JSON. Beacause when I used following code it started working and I can see Enhanced API as request type in PBI service.

Following the final code I used:

var body = @"{
                " + "\n" +
                @"    ""type"": ""Full"",
                " + "\n" +
                @"    ""commitMode"": ""transactional"",
                " + "\n" +
                @"    ""maxParallelism"": 2,
                " + "\n" +
                @"    ""retryCount"": 2,
                " + "\n" +
                @"    ""objects"": [
                " + "\n" +
                @"        {
                " + "\n" +
                @"            ""table"": ""TableName""
                " + "\n" +
                @"            
                " + "\n" +
                @"        }
                " + "\n" +
                @"    ]
                " + "\n" +
                @"}";

            HttpClient client = new HttpClient();
            client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", aadService.GetAccessToken());
            try
            {
                var test = await client.PostAsync($"https://api.powerbi.com/v1.0/myorg/groups/{groupid}/datasets/{datasetId}/refreshes",
                                   new StringContent(body, Encoding.UTF8, "application/json"));
            }
            catch (System.Exception)
            {
                throw;
            }

 

Thanks Ibendlin for your support.

lbendlin
Super User
Super User

Your parameters have the wrong structure.

 

Enhanced refresh with the Power BI REST API - Power BI | Microsoft Learn

 

 

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon & SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.