如何使用 API update/edit 刷新时间表?

How to update/edit refresh schedules using API?

我们有 100 份报告在刷新计划中落后,Microsoft 向我们确认这就是它的工作方式:刷新按 FIFO 排队,因此服务器上的刷新计划越多,它就会越多花时间让报告轮到他们刷新,不管时间表预期如何。

经过讨论,我们决定建立刷新计划治理,因此用户不会创建计划,我们会。但是有数百个时间表(每个报告 1 个),手动更新它们将花费很长时间。

我们如何更新时间表,比如每天上午 10 点或下午 2 点执行刷新?

我能够深入了解 cacherefreshplan 信息,但我不确定如何 "update it" 使用新值。在 swagger 上,我看到了 PUT,但不确定这是否是正确的方法...

    $refreshplan = Invoke-RestMethod -UseDefaultCredentials <# -Credential $creds #> -uri $($baseURI + "api/v2.0/PowerBIReports(path='" + "/Prototypes/report 1" + "')/CacheRefreshP
lans")

$refreshplan.value.ScheduleDescription

At 2:00 AM every day, starting 9/5/2019

$refreshplan.value.Schedule.Definition

StartDateTime             EndDate              EndDateSpecified Recurrence
-------------             -------              ---------------- ----------
2019-09-05T02:00:00-04:00 0001-01-01T00:00:00Z            False @{MinuteRecurrence=; DailyRecurrence=; WeeklyRecurrence=; MonthlyRecurrence=; MonthlyDOWRecurrence=}


$refreshplan.value.Schedule.Definition.StartDateTime

2019-09-05T02:00:00-04:00

您需要致电 Update Refresh Schedule In Group API 并传递新的时间表,例如:

{
  "value": {
    "days": [
      "Sunday",
      "Tuesday",
      "Friday",
      "Saturday"
    ],
    "times": [
      "07:00",
      "11:30",
      "16:00",
      "23:30"
    ],
    "localTimeZoneId": "UTC"
  }
}

要查找群组,您可以使用 Get Groups API and enumerate over datasets in a group using Get Datasets In Group API,当然,您也可以自己准备一个列表。

想通了!

$refreshplan = Invoke-RestMethod -UseDefaultCredentials -uri $($webPortalURL + "/api/v2.0/PowerBIReports(path='/PBIReport/ConnectionStringIM')/CacheRefreshPlans") 

$body = @{
    "@odata.context" = $($webPortalURL)+"/api/v2.0/`$metadata#CacheRefreshPlans/`$entity";
    "Id" = $($refreshplan.value[0].Id);
    "CatalogItemPath" = $($refreshplan.value[0].CatalogItemPath);
    "EventType" = $($refreshplan.value[0].EventType);
    "Schedule" = @{
        "ScheduleID" = $null;
        "Definition"= @{
            "StartDateTime" = "2020-03-18T05:00:00+05:30";
            "EndDate" = "0001-01-01T00:00:00Z";
            "EndDateSpecified" = $false;
            "Recurrence" = @{
                "DailyRecurrence" = @{
                    "DaysInterval"=1
                }
            }
        }
    };
    "ParameterValues" = @();
}

Invoke-RestMethod -UseDefaultCredentials -uri $($webPortalURL + "/api/v2.0/CacheRefreshPlans(e794244c-6743-4100-a9e7-f6eab486fc30)") -Method Put -Body ($body | ConvertTo-Json -Depth 100) -ContentType "application/json"