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

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.

Reply
Anonymous
Not applicable

Post request to refresh dataset

Hi,

I want to create an app which would refresh my dataset when needed by using Power BI REST API post method https://api.powerbi.com/v1.0/myorg/datasets/{datasetId}/refreshes.

When I send POST request I get back response code "unauthorized". Can't figure out where should be a problem. I have all grants permisions for my app in Azure AD. I'm following this tutorial to get access token https://docs.microsoft.com/en-us/power-bi/developer/automation/walkthrough-push-data-get-token. For request I add header with token, body with "notifyOption" and path with my datasetId. Do I miss some parameters or I am using a wrong access token? 

 

My code sample

HttpClient httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {token}");
var requestBody = new JObject();
requestBody["notifyOption"] = "";
var response = await httpClient.PostAsync(
"https://api.powerbi.com/v1.0/myorg/datasets/****datasetid***/refreshes",
new StringContent(requestBody.ToString(), Encoding.UTF8, "application/json"));
           



0 REPLIES 0

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.