Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi,
I'm making use of the new Dataset Refresh API, and the documentation states that a status code of 409 Conflict is returned when a refresh is already executing. However, I am receiving a 400 Bad Request for that exact scenario. I would prefer it if the implementation was matching the docs, hence if it was possible to distinguish the refresh-in-progress condition from any other generic API errors. Querying the Refresh History endpoint instead is not a viable alternative either because it only returns a status of "Unknown" when a refresh is in progress - again, making it impossible to distinguish that state from any other that might be deemed "unknown",
Thanks,
Mathias
I am always getting the "Operation returned an invalid status code 'UnsupportedMediaType'" error everytime I try to refresh a dataset.
Snippet
var refreshData = client.Datasets.RefreshDatasetInGroup(cloneGroup.Id, report.DatasetId) as Datasets;
@Anonymous wrote:
I am always getting the "Operation returned an invalid status code 'UnsupportedMediaType'" error everytime I try to refresh a dataset.
Snippet
var refreshData = client.Datasets.RefreshDatasetInGroup(cloneGroup.Id, report.DatasetId) as Datasets;
@Anonymous
What is the dataset in your case? What if you go with my demo calling REST API instead of using the SDK?
@Anonymous @Eric_Zhang
I'm facing the same issue
Getting "Operation returned an invalid status code 'UnsupportedMediaType'" using the SDK as well as the REST API
@Anonymous Were you able to resolve the issue?
Update - Able to get it to work in Import mode. Earlier I was trying the refresh with DirectQuery.
I guess Refresh for datasets in DirectQuery mode isn't supported.
@Eric_Zhang I am getting "Invalid Dataset. This API can only be called on a Model-base dataset" when I use your demo.. Not sure what it means.
@Anonymous wrote:
@Eric_Zhang I am getting "Invalid Dataset. This API can only be called on a Model-base dataset" when I use your demo.. Not sure what it means.
@Anonymous
What is the datasource in your dataset?
@mthierba wrote:
Hi,
I'm making use of the new Dataset Refresh API, and the documentation states that a status code of 409 Conflict is returned when a refresh is already executing. However, I am receiving a 400 Bad Request for that exact scenario. I would prefer it if the implementation was matching the docs, hence if it was possible to distinguish the refresh-in-progress condition from any other generic API errors. Querying the Refresh History endpoint instead is not a viable alternative either because it only returns a status of "Unknown" when a refresh is in progress - again, making it impossible to distinguish that state from any other that might be deemed "unknown",
Thanks,
Mathias
Thanks for reporting that. I can reproduce the behavior of returning 400 while 409 is expected. I'm going to consulting this internally and as a workaround, you cound find the 400 error message to determine "refresh is executing".
static void refreshDataset(string groupId, string datasetId) { HttpWebRequest request = System.Net.HttpWebRequest.CreateHttp(String.Format("https://api.powerbi.com/v1.0/myorg/groups/{0}/datasets/{1}/refreshes", groupId, datasetId)); //POST web request to create a datasource. request.KeepAlive = true; request.Method = "POST"; request.ContentLength = 0; //Add token to the request header request.Headers.Add("Authorization", String.Format("Bearer {0}", token)); try { //Write JSON byte[] into a Stream using (Stream writer = request.GetRequestStream()) { var response = (HttpWebResponse)request.GetResponse(); Console.WriteLine("Dataset refresh request {0}", response.StatusCode.ToString()); } } catch (WebException wex) { if (wex.Response != null) { using (var errorResponse = (HttpWebResponse)wex.Response) { using (var reader = new StreamReader(errorResponse.GetResponseStream())) { string errorString = reader.ReadToEnd(); dynamic respJson = JsonConvert.DeserializeObject<dynamic>(errorString);
//if refreshing is executing, the output would be "Invalid dataset refresh request. Another refresh request is already executing" Console.WriteLine(respJson["error"]["message"]); } } } } }
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
4 | |
3 | |
3 | |
3 | |
2 |