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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
shyamganesh
Frequent Visitor

Subscribing Power BI reports through API

Hi All,

I am trying to do subscribing reports through REST API. But i am not able to do it through API. I knew we can make through Power Automate and in my case i need to do from API end. Is there any solution?

https://learn.microsoft.com/en-us/rest/api/power-bi-report/subscriptions  --- these existing api is not working as expected. Anyother ideas?  

9 REPLIES 9
felaray
Frequent Visitor

Hi @felaray 
Any others ideas apart from power automate?

 

It is not related to Power Automate, but rather to the Power BI API. I am unable to make calls using Postman because Microsoft has not made the relevant API available.

Expiscornovus
Super User
Super User

Hi @shyamganesh,

 

Have you tried the Admin - Reports GetReportSubscriptionsAsAdmin method instead?

https://learn.microsoft.com/en-us/rest/api/power-bi/admin/reports-get-report-subscriptions-as-admin

 

https://api.powerbi.com/v1.0/myorg/admin/reports/{reportId}/subscriptions

 

Btw, are you testing in Postman? If not, that is probably easier to test.



Happy to help out 🙂

I share #PowerAutomate and #SharePointOnline content on my Blog, Bluesky profile or Youtube Channel

@Expiscornovus This is a read-only API that can retrieve subscription-related information. Unfortunately, it does not support write operations.

Hi @Expiscornovus 

shyamganesh_0-1729590219278.png

The API you meantioned is not for creating subscription for power bi reports. I am not using postman though

Hi @shyamganesh,

 

My bad, I missed that body payload with the schedule. I thought you were collecting/retrieving subscriptions from the existing report on the Power BI Online service.

 

The link you were referring to in your opening post was a REST API call from Power BI report server (on-premise). Like @felaray already mentioned, that method doesn't exist in the Online APIs.



Happy to help out 🙂

I share #PowerAutomate and #SharePointOnline content on my Blog, Bluesky profile or Youtube Channel
Expiscornovus
Super User
Super User

Hi @shyamganesh,

 

When you say, it doesn't work as expected, what do you mean? Are you getting an error code?

 

If so, can you share a screenshot of your current flow setup that is not working (or explain it in more detail)?



Happy to help out 🙂

I share #PowerAutomate and #SharePointOnline content on my Blog, Bluesky profile or Youtube Channel

Hi @Expiscornovus 

This is code i used for subcribing reports through API

--Code--

import requests
import json

# Define constants
CLIENT_ID = '#######################'
CLIENT_SECRET = '#######################'
TENANT_ID = '#######################'
RESOURCE = 'https://analysis.windows.net/powerbi/api'
API_URL = 'https://api.powerbi.com/v1.0/myorg/groups/{GROUP_ID}/reports/{REPORT_ID}/subscriptions'

def get_access_token():
url = f'https://login.microsoftonline.com/{TENANT_ID}/oauth2/v2.0/token'
headers = {
'Content-Type': 'application/x-www-form-urlencoded'
}
body = {
'grant_type': 'client_credentials',
'client_id': CLIENT_ID,
'client_secret': CLIENT_SECRET,
'scope': RESOURCE + '/.default'
}
response = requests.post(url, headers=headers, data=body)
if response.status_code == 200:
return response.json().get('access_token')
else:
print(f"Failed to obtain access token. Status Code: {response.status_code}, Response: {response.text}")
return None

def create_subscription(access_token, group_id, report_id):
url = API_URL.format(GROUP_ID=group_id, REPORT_ID=report_id)
headers = {
'Authorization': f'Bearer {access_token}',
'Content-Type': 'application/json'
}
data = {
"displayName": "My Subscription",
"schedule": {
"frequency": "Daily",
"timeZone": "Pacific Standard Time",
"times": ["07:00"]
},
"status": "Enabled"
}
response = requests.post(url, headers=headers, json=data)
if response.status_code == 201:
print("Subscription created successfully.")
else:
print(f"Failed to create subscription. Status Code: {response.status_code}, Response: {response.text}")

if __name__ == "__main__":
# Replace with your workspace and report IDs
GROUP_ID = '########################'
REPORT_ID = '#######################'

token = get_access_token()
if token:
create_subscription(token, GROUP_ID, REPORT_ID)

Error 

Failed to create subscription. Status Code: 404, Response: {
  "error":{
    "code":"","message":"No HTTP resource was found that matches the request URI}}

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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