cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
alexisc67
Helper I
Helper I

API Refreshes Data Set 400 Bad Request error after first time

Hi,

 

I am not able to find the problem with an API call to refresh a dataset. It worked once and it doesn't anymore. It gives a 400 Bad Request Error on GetResponse(). The call works if I do a GET which gives me the refresh history, no problem. The POST doesn't work after the first time it did.

 

The call is made by a WebApp that resides in Azure. The dataset is an import from Azure SQL.

 

The code is below:

 

protected void UpdateReport(int index)
{
try
{
// Create a request using a URL that can receive a post.
System.Net.WebRequest request = System.Net.WebRequest.Create("https://api.powerbi.com/v1.0/company/groups/325d21e4-403b-455f-0000-XXXXXXXXX/datasets/b19ac36a-bb5b-XXXXXXXXXX/refreshes");
// Set the Method property of the request to POST.
request.Method = "POST";
request.Headers.Add("Authorization", String.Format("Bearer {0}", accessToken.Value));
// Set the ContentType property of the WebRequest.
request.ContentType = "application/x-www-form-urlencoded";
// Set the ContentLength property of the WebRequest.
request.ContentLength = 0;
System.Net.WebResponse response = request.GetResponse();
// Display the status.
System.IO.Stream dataStream = response.GetResponseStream();
// Open the stream using a StreamReader for easy access.
System.IO.StreamReader reader = new System.IO.StreamReader(dataStream);
// Read the content.
string responseFromServer = reader.ReadToEnd();
// Display the content.
txtResponseFromServer.Text = responseFromServer;
//Console.WriteLine(responseFromServer);
// Clean up the streams.
reader.Close();
dataStream.Close();
response.Close();
}

catch (Exception e)
{
txtResponseFromServer.Text = String.Format("An error occurred: '{0}'", e);
}
}

 

Any help is appreaciated.

 

Thanks,

Alexis

5 REPLIES 5
v-micsh-msft
Microsoft
Microsoft

Hi,

 

Error 400 is an HTTP general error.

 

 

Try to replace the URL with the following:

 

https://api.powerbi.com/v1.0/myorg/groups/325d21e4-403b-455f-0000-XXXXXXXXX/datasets/b19ac36a-bb5b-XXXXXXXXXX/refreshes

 

Under the 

 

System.Net.WebRequest.Create

 

function, then check the results.

 

Regards,

Michael

Hi again,

 

I tried with a new report. Again, it worked for a few times initially and now it doesn't work anymore with a 400 Bad Request error.

 

refreshdataset.PNG

Could it be that you hit the refresh limit of 8 refreshes per day (or 48 in case of a workspace on a Premium node)?

Hi alexisc67,

 

This happened to me once but I don't remember if it was 400 bad request error. How many times do you refreshed it? The maximum ammount of refreshes in a day is 8. If you exceded it will stop to work.

 

If you need to refresh more than 8 times you should consider a streaming dataset.

 

Best regards,

Alexsander

Hi,

 

Thansk for the response. I have tried using 'myorg' and also my company name in this place. I get the same result. Isn't strange that the GET works fine and the POST doesn't. Also, why worked once and not after.

 

If you can think of something else I can check, please let me know.

 

Alexis

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

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

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.