I manage to run a Report refresh from the API when the CacheRefreshPlan already exists. But now i would like to create the CacheRefreshPlan if none exists for the report I want to refresh. How is it possible to do this with the PowerBi Server on prem API ?
Here is my code:
data = """{
"@odata.context": "https://myserver.com/ReportsPBI/api/v2.0/$metadata#CacheRefreshPlans",
"value": [
{
"Id": null,
"Owner": null,
"Description": "API created CacheRefreshPlan",
"CatalogItemPath": "/path/reportname",
"EventType": "DataModelRefresh",
"ScheduleDescription": "At 2:00 AM on 11/21/2022",
"LastRunTime": null,
"LastStatus": null,
"ModifiedBy": null,
"ModifiedDate": "2022-11-21T16:04:48.187+01:00",
"Schedule": {
"ScheduleID": null,
"Definition": {
"StartDateTime": "2022-11-21T02:00:00+01:00",
"EndDate": "0001-01-01T00:00:00Z",
"EndDateSpecified": false,
"Recurrence": {
"MinuteRecurrence": null,
"DailyRecurrence": null,
"WeeklyRecurrence": null,
"MonthlyRecurrence": null,
"MonthlyDOWRecurrence": null
}
}
},
"ParameterValues": []
}
]
}"""
import requests, json
url = 'https://myserver.com/ReportsPBI/api/v2.0/CacheRefreshPlans'
s = requests.Session()
s.verify = False
s.auth = auth
headers = {'Content-type':'application/json', 'Accept':'application/json'}
response = s.post(url, data= json.loads(data), headers=headers, verify=False)
print(response.status_code)
I run this and I have a 400 Bad Request response.status_code to my post request.
Do you know what is missing, and/or what are the other steps to make it work ?
Which fields are mandatory or not ? A minimal json payload working example would be nice. How to I generate an Id if needed ?
I found and read some docs , but did not found working examples and/or detailed enough for me: https://app.swaggerhub.com/apis/microsoft-rs/PBIRS/2.0#/CacheRefreshPlans/AddCacheRefreshPlan