KaranSingh
KaranSingh

Reputation: 630

How to create a Power BI DataSet Scheduled Refresh programatically

Requirement: To create a Power BI Dataset scheduled refresh through code and use it in DevOps process, so that I do not have to create scheduled refresh explicitly from Power BI web portal.

What I tried/research: I could not find Power BI API explicitly to create scheduled refresh. So, I tried to use update refresh schedule datasets API: https://api.powerbi.com/v1.0/myorg/datasets/{datasetId}/refreshSchedule Refer: MicrosoftDocs

Observed: If the schedule is OFF - this API turns ON the schedule and updates the refresh schedule of the dataset. However, to achieve this I had to create schedule at least once using the Power BI web portal. Then if I turn off the schedule and run the above API, it turns ON the schedule and updates refresh schedule timings.

Are any workarounds to setup a Power BI Dataset scheduled refresh via API?

Upvotes: 0

Views: 1222

Answers (1)

Willem Genuit
Willem Genuit

Reputation: 26

Yes there is by using the 'Update refresh schedule in group' endpoint:

https://api.powerbi.com/v1.0/myorg/groups/{groupId}/datasets/{datasetId}/refreshSchedule

Refer: Microsoft

In the body you can specify your schedule. I use this in a python script to set my schedules automatically. As body I use:

 {"value": 
    {"days":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],
     "times": ["05:00"],
     "enabled": 'true',
     "localTimeZoneId": "UTC"
  }}

Upvotes: 0

Related Questions