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.
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"));
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.
User | Count |
---|---|
14 | |
2 | |
2 | |
1 | |
1 |