Forum Discussion
API Call - Help with "Add Cache Refresh Plan"
I'd like to be able to programmatically create a Cache Refresh Plan attached to a particular report hosted on our Report Server.
I can manually create a plan under "Scheduled refresh" when I manage the report via the Report Server web portal.
I have found documentation for the API here: https://learn.microsoft.com/en-us/rest/api/power-bi-report/cache-refresh-plans/add-cache-refresh-plan ... However, there doesn't seem to be a sample body or template which I can model my own API call, and I don't seem to be able to catch the call in my browser network-watch dev tool . I have successfully done a few other API commands, like deleting and adding Power BI Reports.
Is there a location I can look for more thorough documentation, or can someone provide me with a sample?
I'm not sure why they moved away from using SwaggerHub for documentation, but the docs there still have an example of how to call this api https://app.swaggerhub.com/apis/microsoft-rs/PBIRS/2.0#/CacheRefreshPlans/AddCacheRefreshPlan And when I use the browser tools in Edge it captures the POST call to create a cache refresh plan.
Below is an example I captured when creating a scheduled refresh for my Power BI report called "local Adv Works"{ "Owner": null, "Description": "test2", "CatalogItemPath": "/local Adv Wrks", "EventType": "DataModelRefresh", "Schedule": { "ScheduleID": null, "Definition": { "StartDateTime": "2025-07-01T04:00:00+10:00", "EndDateSpecified": false, "EndDate": "1901-02-01T00:00:00+10:00", "Recurrence": { "DailyRecurrence": { "DaysInterval": 1 } } } }, "ScheduleDescription": "", "ParameterValues": [] }
4 Replies
- d_gosbellSuper User
I'm not sure why they moved away from using SwaggerHub for documentation, but the docs there still have an example of how to call this api https://app.swaggerhub.com/apis/microsoft-rs/PBIRS/2.0#/CacheRefreshPlans/AddCacheRefreshPlan And when I use the browser tools in Edge it captures the POST call to create a cache refresh plan.
Below is an example I captured when creating a scheduled refresh for my Power BI report called "local Adv Works"{ "Owner": null, "Description": "test2", "CatalogItemPath": "/local Adv Wrks", "EventType": "DataModelRefresh", "Schedule": { "ScheduleID": null, "Definition": { "StartDateTime": "2025-07-01T04:00:00+10:00", "EndDateSpecified": false, "EndDate": "1901-02-01T00:00:00+10:00", "Recurrence": { "DailyRecurrence": { "DaysInterval": 1 } } } }, "ScheduleDescription": "", "ParameterValues": [] }- z-rmoNew Member
Thank you for the Swagger link and the message body example! The Swagger will be a useful resource going forward--until Microsoft releases a new version of the API, I suppose.
Turns out that I was close, having modeled a JSON object from a GET response. However, I was providing a null "ID" value which was not wanted by the server for the POST.
- z-rmoNew Member
I am using Power BI Report Server (January 2025), version 1.22.9153.7886.
- rohit1991Super User
Hi z-rmo ,
The docs are a bit lacking when it comes to real-world examples for the "Add Cache Refresh Plan" call. I ran into this myself and here’s what actually worked for me:
1. Use the official SwaggerHub for PBIRS: It’s much more helpful than the standard docs, and you can see exactly what the body should look like.
2. Sample JSON payload: When you create a scheduled refresh via the Report Server portal, the API call looks like this (you can check using browser dev tools):{ "Owner": null, "Description": "Your description here", "CatalogItemPath": "/your/path/to/report", "EventType": "DataModelRefresh", "Schedule": { "ScheduleID": null, "Definition": { "StartDateTime": "2025-07-01T04:00:00+10:00", "EndDateSpecified": false, "EndDate": "1981-02-01T00:00:00+10:00", "Recurrence": { "DailyRecurrence": { "DaysInterval": 1 } } } }, "ScheduleDescription": "", "ParameterValues": [] }Heads up: Leave ScheduleID as null or just omit it. Make sure CatalogItemPath matches your report’s path exactly.