Forum Discussion
update-refresh-schedule-in-group error 415 Unsupported media type using powershell
- 1 year ago
https://github.com/mschoombee/Blog/blob/main/2020/automating-power-bi-deployments/Reports%20-%20Update%20Refresh%20Schedule.ps1
on this github site I found the solution.# https://learn.microsoft.com/en-us/rest/api/power-bi/datasets/update-refresh-schedule-in-group ## once in a lifetime you got to do this: ## Install-Module -Name MicrosoftPowerBIMgmt ## somtimes in a lifetime you got to do this: ## Update-Module -Name MicrosoftPowerBIMgmt ## Depending on your execution policy do not forget to trust the session ## Set-ExecutionPolicy -ExecutionPolicy remotesigned -Scope Process ## login to the platform Login-PowerBI ##Build the body $ApiRequestBody = @" { "value": { "days": [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ], "times": [ "08:00", "08:30" ], "notifyOption": "MailOnFailure", "localTimeZoneId": "UTC", "enabled": true } } "@ ## Invoke the API but do not include the header Invoke-PowerBIRestMethod -Url 'https://api.powerbi.com/v1.0/myorg/groups/74601087-ad5e-481c-a20c-1965baa8607b/datasets/d469f67e-4568-49eb-b6bc-e42f2c5d37d5/refreshSchedule' -Method Patch -Body ("$ApiRequestBody")I tried to schedule between full and half hours but then the response is
Invoke-PowerBIRestMethod : Encountered errors when invoking the command: {
"code": "InvalidRequest",
"message": "Refresh schedule time must be full or half hour (HH:00 or HH:30)" so if you can live with that this is the solution
https://github.com/mschoombee/Blog/blob/main/2020/automating-power-bi-deployments/Reports%20-%20Update%20Refresh%20Schedule.ps1
on this github site I found the solution.
# https://learn.microsoft.com/en-us/rest/api/power-bi/datasets/update-refresh-schedule-in-group
## once in a lifetime you got to do this:
## Install-Module -Name MicrosoftPowerBIMgmt
## somtimes in a lifetime you got to do this:
## Update-Module -Name MicrosoftPowerBIMgmt
## Depending on your execution policy do not forget to trust the session
## Set-ExecutionPolicy -ExecutionPolicy remotesigned -Scope Process
## login to the platform
Login-PowerBI
##Build the body
$ApiRequestBody = @"
{
"value": {
"days": [
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
],
"times": [
"08:00",
"08:30"
],
"notifyOption": "MailOnFailure",
"localTimeZoneId": "UTC",
"enabled": true
}
}
"@
## Invoke the API but do not include the header
Invoke-PowerBIRestMethod -Url 'https://api.powerbi.com/v1.0/myorg/groups/74601087-ad5e-481c-a20c-1965baa8607b/datasets/d469f67e-4568-49eb-b6bc-e42f2c5d37d5/refreshSchedule' -Method Patch -Body ("$ApiRequestBody")
I tried to schedule between full and half hours but then the response is
Invoke-PowerBIRestMethod : Encountered errors when invoking the command: {
"code": "InvalidRequest",
"message": "Refresh schedule time must be full or half hour (HH:00 or HH:30)" so if you can live with that this is the solution