Forum Discussion

mihirsp1988's avatar
mihirsp1988
Frequent Visitor
3 years ago
Solved

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 tab...
  • mihirsp1988's avatar
    mihirsp1988
    3 years ago

    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.