I am trying to create an API request to create a RefreshPlan for an existing report which has None. I want to do it with the API. My powerbi server is on prem. I tried to follow the docs and openapi spec here:

https://app.swaggerhub.com/apis/microsoft-rs/pbirs/2.0

My code:

payload = {
  "Id": "01234567-89ab-cdef-0123-456789abcdef",
  "Owner": "string",
  "Description": "string",
  "CatalogItemPath": "string",
  "EventType": "string",
  "Schedule": {
    "ScheduleId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "Definition": {
      "StartDateTime": "2017-04-13T15:51:04Z",
      "EndDate": "2017-04-13T15: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": "2017-04-13T15:51:04Z",
  "LastStatus": "string",
  "ModifiedBy": "string",
  "ModifiedDate": "2017-04-13T15:51:04Z",
  "ParameterValues": [
    {
      "Name": "string",
      "Value": "string",
      "IsValueFieldReference": "true"
    }
  ]
}


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= payload, headers=headers, verify=False)

print(response.status_code)
print(response.text)

The output and final error code and error message I get are:

400

{"error":{"code":"","message":"The entity type \'Model.PowerBIReport\' is not compatible with the base type \'Model.CacheRefreshPlan\' of the provided entity set \'Model.Container.CacheRefreshPlans\'. When an entity type is specified for an OData resource set or resource reader, it has to be the same or a subtype of the base type of the specified entity set."}}

How can I resolve this error ?

I suppose the API call: url and/or payload is wrong but I cannot find how to fix this. Any help is welcome.

0

There are 0 answers