Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
MaxMuster
Frequent Visitor

Struggling to create refresh plan with rest API

I try to create a new refresh plan for a power bi report on the report server.

According to the documentation this should be possible with POST command:

https://app.swaggerhub.com/apis/microsoft-rs/PBIRS/2.0#/CacheRefreshPlans/AddCacheRefreshPlan

http://localhost/reports/api/v2.0/CacheRefreshPlans

I'm using postman and in the body I have something like this:

{
"Id": "01234567-89ab-cdef-0123-456789abcdef",
"Owner": "Username",
"Description": "TestRefresh",
"CatalogItemPath": "/path/to/report",
"EventType": "DataModelRefresh",
"Schedule": {
"ScheduleId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"Definition": {
"StartDateTime": "2021-09-21T15:51:04Z",
"EndDate": "2021-09-29T15:51:04Z",
"EndDateSpecified": true,
"Recurrence": {
"MinuteRecurrence": {
"MinutesInterval": 0
},
"DailyRecurrence": {
"DaysInterval": 0
},
"WeeklyRecurrence": {
"WeeksInterval": 0,
"WeeksIntervalSpecified": true,
"DaysOfWeek": {
"Sunday": true,
"Monday": true,
"Tuesday": true,
"Wednesday": true,
"Thursday": true,
"Friday": true,
"Saturday": true
}
},
"MonthlyRecurrence": {
"Days": "string",
"MonthsOfYear": {
"January": true,
"February": true,
"March": true,
"April": true,
"May": true,
"June": true,
"July": true,
"August": true,
"September": true,
"October": true,
"November": true,
"December": true
}
},
"MonthlyDOWRecurrence": {
"WhichWeek": "FirstWeek",
"WhichWeekSpecified": true,
"DaysOfWeek": {
"Sunday": true,
"Monday": true,
"Tuesday": true,
"Wednesday": true,
"Thursday": true,
"Friday": true,
"Saturday": true
},
"MonthsOfYear": {
"January": true,
"February": true,
"March": true,
"April": true,
"May": true,
"June": true,
"July": true,
"August": true,
"September": true,
"October": true,
"November": true,
"December": true
}
}
}
}
},
"LastRunTime": null,
"LastStatus": null,
"ModifiedBy": null,
"ModifiedDate": null,
"ParameterValues": []
}

 

But I always get "500 InternalServer Error" response. Is there something wrong with the json or could it be an other problem?

Unfortunally I did not find a detailed example on how to use the CacheRefreshPlans Api.

1 ACCEPTED SOLUTION
d_gosbell
Super User
Super User

It's probably an issue with the json payload since the Report Portal itself uses the REST api to create schedules.

 

So what I would suggest is to open the browser developer tools and go to the network tab (I normally use Chrome or the new Edge for this sort of thing). Then create a schedule in the portal that is the same sort of thing that you would want to creat using the API. You should then see the relevant POST calls in the networking tab with real examples of valid json payloads.

 

You could then delete these example schedules and then re-execute the same requests using Postman.

View solution in original post

4 REPLIES 4
MaxMuster
Frequent Visitor

This is the payload in the report portal for a simple refresh plan:

 

{
"Owner":null,
"Description":"someDescription",
"CatalogItemPath":"/path/to/pbiReport",
"EventType":"DataModelRefresh",
"Schedule":{
"ScheduleID":null,
"Definition":{
"StartDateTime":"2021-09-22T02:00:00+02:00",
"EndDateSpecified":false,
"EndDate":"1901-02-01T00:00:00+01:00",
"Recurrence":{
"DailyRecurrence":{
"@odata.type":"#Model.DailyRecurrence","DaysInterval":1
}
}
}
},
"ScheduleDescription":"",
"ParameterValues":[]
}

 

I checked the logs but the error is not really telling me anything (file: RSportal_date.log):

 

2021-09-22 10:04:53.7689|INFO|113|Received request POST /api/v2.0/CacheRefreshPlans| RequestID = s_d5e5c8ae-e59f-4603-9efb-4f6feb155c79

2021-09-22 10:04:53.7689|ERROR|113|OData exception occurred: System.Web.Http.HttpResponseException: Processing of the HTTP request resulted in an exception. Please see the HTTP response returned by the 'Response' property of this exception for details.
at System.Web.Http.ModelBinding.FormatterParameterBinding.ReadContentAsync(HttpRequestMessage request, Type type, IEnumerable`1 formatters, IFormatterLogger formatterLogger, CancellationToken cancellationToken)
at System.Web.Http.ModelBinding.FormatterParameterBinding.ReadContentAsync(HttpRequestMessage request, Type type, IEnumerable`1 formatters, IFormatterLogger formatterLogger)
at System.Web.Http.ModelBinding.FormatterParameterBinding.<ExecuteBindingAsyncCore>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Web.Http.Controllers.HttpActionBinding.<ExecuteBindingAsyncCore>d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__6.MoveNext().| RequestID = s_d5e5c8ae-e59f-4603-9efb-4f6feb155c79

 

ReportingServicesService_*.log does not seem to contain any related error to my post requests.

d_gosbell
Super User
Super User

It's probably an issue with the json payload since the Report Portal itself uses the REST api to create schedules.

 

So what I would suggest is to open the browser developer tools and go to the network tab (I normally use Chrome or the new Edge for this sort of thing). Then create a schedule in the portal that is the same sort of thing that you would want to creat using the API. You should then see the relevant POST calls in the networking tab with real examples of valid json payloads.

 

You could then delete these example schedules and then re-execute the same requests using Postman.

Thank you, I tried it and found that the payload differed from what I previously used.

Unfortunally I still get an 500 internal server error when posting the same payload that is used to create a schedule from the report portal with postman. Maybe something else is still wrong, I will make some more tests.


@MaxMuster wrote:

Thank you, I tried it and found that the payload differed from what I previously used.

Yes, there were a few fields in there like LastRunTime and LastStatus which I would not expect to be writeable. 

 


@MaxMuster wrote:

Unfortunally I still get an 500 internal server error when posting the same payload that is used to create a schedule from the report portal with postman. Maybe something else is still wrong, 


So the other thing you could do would be to check the log files which should be in the following location:

 

C:\Program Files\Microsoft Power BI Report Server\PBIRS\LogFiles

 

There a number of services that make up Power BI Report Server and you would be looking for logs that start with ReportingServicesService_*.log the most recent file should hopefully have more details about what caused the 500 error.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.