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

Shape the future of the Fabric Community! Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions. Take survey.

Reply
mthierba
Advocate I
Advocate I

Refresh Dataset API returns 400 Bad Request when refresh is in progress

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

7 REPLIES 7
Anonymous
Not applicable

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.

 

 

Anonymous
Not applicable

@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?

Eric_Zhang
Microsoft Employee
Microsoft Employee


@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


@mthierba

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"]); } } } } }

 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.