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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Failing: Datasets.UpdateRefreshScheduleInGroupAsync in .NET library throws Bad Request exception

We are writing a C# application to automate the creation of datasets for specific customers in a Power BI Embedded Capacity (v2). We are using latest versions of the following Nuget packages: Microsoft.PowerBI.API (v4.2.0) ("REST API Library") and Microsoft.AnalysisServices.NetCore.retail.amd64 (v.19.32.0) ("TOM API Library"). We authenticate our API calls with access tokens issued to an AAD Service Principal which, as far as we know, has all necessary permissions in Power BI.

We are able to:

  1. Create a unique workspace for the customer (using REST API Library)
  2. Create a unique data source for the customer in a shared on-premise data gateway (using REST API Library)
  3. Copy a "master" dataset into the customer's workspace (using TOM API Library)
  4. Bind the customer's copy of the dataset to the customer's data source in the on-premise gateway (using REST API Library)
  5. Execute a single command to refresh the customer's copy of the dataset (using REST API Library)

But we get a 400 Bad Request when we try to create a refresh schedule for the dataset. We call Datasets.UpdateRefreshScheduleInGroupAsync() with what we believe are the correct parameters. Here is the code:

var schedule = new RefreshSchedule
{
Days = new List<Days?> { Days.Monday },
Times = new List<string> { "01:00" },
LocalTimeZoneId = "Eastern Standard Time",
Enabled = true

};

await restApiClient.Datasets.UpdateRefreshScheduleInGroupAsync(
workspaceId,
datasetId.ToString(),
schedule);

It throws Exception: 400 Bad Request. We receive no other information about what caused the failure.

We have tried sending a RefreshSchedule without setting any properties except Enabled = true, and also sending a RefreshSchedule with only Days and Enabled properties set. No matter what properties we set, we always get Exception: 400 Bad Request.

 

How do we make this work?

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

No one else replied, but I found the solution. The RefeshSchedule needs to set NotifyOption to ScheduleNotifyOption.NoNotification. That's apparently because the dataset owner is a service principal, and NoNotification is apparently not the default. 

 

var schedule = new RefreshSchedule
{
Days = new List<Days?> { Days.Monday },
Times = new List<string> { "01:00" },
LocalTimeZoneId = "Eastern Standard Time",
Enabled = true,
NotifyOption = ScheduleNotifyOption.NoNotification
};

Microsoft, would you please document this so we don't spend days figuring it out?

View solution in original post

1 REPLY 1
Anonymous
Not applicable

No one else replied, but I found the solution. The RefeshSchedule needs to set NotifyOption to ScheduleNotifyOption.NoNotification. That's apparently because the dataset owner is a service principal, and NoNotification is apparently not the default. 

 

var schedule = new RefreshSchedule
{
Days = new List<Days?> { Days.Monday },
Times = new List<string> { "01:00" },
LocalTimeZoneId = "Eastern Standard Time",
Enabled = true,
NotifyOption = ScheduleNotifyOption.NoNotification
};

Microsoft, would you please document this so we don't spend days figuring it out?

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.