DaiKeung
DaiKeung

Reputation: 1167

Power BI C# API: How to update refreshSchedule of the datasets?

Below is error that I could not update refreshSchedule of the datasets:

{
  "error": {
     "code": "InvalidRequest",
     "message": "Invalid NotifyOption value 'MailOnFailure' for app only owner requests"
  }
}

Below is code to call it:

var datasets = await client.Datasets.GetDatasetsAsync(new Guid(_workspaceId));
var days = new List<Days?> { Days.Monday, Days.Tuesday, Days.Wednesday, Days.Thursday, Days.Friday, Days.Saturday, Days.Sunday };
var times = new List<string> { "00:00" };
var refreshSchedule = new RefreshSchedule(days, times, true, "UTC");
var id = "XXX";

await client.Datasets.TakeOverAsync(new Guid(_workspaceId), id);
var refreshRequest = new RefreshRequest(NotifyOption.NoNotification);
// refresh datasets
await client.Datasets.RefreshDatasetAsync(new Guid(_workspaceId), id, refreshRequest);
// Target: Update RefreshSchedule (Exception for calling this)
await client.Datasets.UpdateRefreshScheduleInGroupAsync(new Guid(_workspaceId), id, refreshSchedule);

Upvotes: 0

Views: 873

Answers (1)

Satya V
Satya V

Reputation: 4164

Can you pls let me know how the app is consuming the endpoint - User Interventaion or Completeley done through AppOnly or using the master user Credential?

Alternatively, if you don't want the MailOnfailure, can you set up explicitly No Notification for the Refresh Schedule and Try ?

just modified your piece of code and presented below :

 var refreshSchedule = new RefreshSchedule(days, times, true, "UTC", ScheduleNotifyOption.NoNotification);

The snippet :

var days = new List<Days?> { Days.Monday, Days.Tuesday, Days.Wednesday, Days.Thursday, Days.Friday, Days.Saturday, Days.Sunday };
var times = new List<string> { "00:00" };
//Fixed code
var refreshSchedule = new RefreshSchedule(days, times, true, "UTC", ScheduleNotifyOption.NoNotification);

await client.Datasets.UpdateRefreshScheduleInGroupAsync(WorkspaceId, datasets.Id, refreshSchedule);

UPDATE

When i used ServicePrincipal (without any UserIntervention/Master User Credential)

I was able to repro your issue

Error Status: BadRequest (400) Response: {"error":{"code":"InvalidRequest","message":"Invalid NotifyOption value 'MailOnFailure' for app only owner requests"}}

I was able to get past the error by making use of the ScheduleNotifyOption.NoNotification in the refreshSchedule mentioned above.

enter image description here

Or if i use the app through cred of a mailenabled account.

Upvotes: 2

Related Questions