Forum Discussion
power bi create schedule refresh api not able to set email ID
Hi Anonymous
Currently there is no option to set the email id to receive email notifications via REST API. You could vote for below idea about this feature: Microsoft Idea ยท Email Notification for Many Users, for Failed Dataset Refresh via REST API (powerbi.com)
When you set notifyOption is MailOnFailure, it will send email notifications to dataset owner by default. However, if you add additional recipients in the Email these users when the refresh fails textbox in Power BI UI, these users can receive email notifications if a dataset refresh fails when triggered via API.
Regards,
Community Support Team _ Jing Zhang
- himanshukhanna4 years agoNew Member
Hi,
I've tried below code, if I set MailOnFailure it fails and when I set NoNotification it passes. I want to send notification to owner.
$ScheduleJsonEnable = '{
"value":
{
"enabled":true,
"notifyOption":"MailOnFailure",
"days":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],
"times":["00:00","01:00","02:00","03:00","04:00","05:00","06:00","07:00","08:00","09:00","10:00","11:00","12:00","13:00","14:00","15:00","16:00","17:00","18:00","19:00","20:00","21:00","22:00","23:00"],
"localTimeZoneId":"UTC"
}
}'Invoke-PowerBIRestMethod -Method Patch -Url groups/$($Workspace.Id.Guid)/datasets/$($Report.DatasetId)/refreshSchedule -Body $ScheduleJsonEnable
Error:
Invoke-PowerBIRestMethod : One or more errors occurred.
At line:1 char:1
+ Invoke-PowerBIRestMethod -Method Patch -Url groups/$($Workspace.Id.Gu ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (Microsoft.Power...werBIRestMethod:InvokePowerBIRestMethod) [Invoke-PowerBIRestMethod], AggregateException
+ FullyQualifiedErrorId : One or more errors occurred.,Microsoft.PowerBI.Commands.Profile.InvokePowerBIRestMethod>>
Resolve-PowerBIError -Last
HistoryId: 9
Message : Response status code does not indicate success: 400 (Bad Request).
StackTrace : at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
at Microsoft.PowerBI.Commands.Profile.InvokePowerBIRestMethod.<InvokeRestMethod>d__35.MoveNext()
Exception : System.Net.Http.HttpRequestException
InvocationInfo : {Invoke-PowerBIRestMethod}
Line : Invoke-PowerBIRestMethod -Method Patch -Url groups/$($Workspace.Id.Guid)/datasets/$($Report.DatasetId)/refreshSchedule -Body $ScheduleJsonEnable
Position : At line:1 char:1
+ Invoke-PowerBIRestMethod -Method Patch -Url groups/$($Workspace.Id.Gu ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId : 9