<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: API for Subcription in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/API-for-Subcription/m-p/4152321#M55287</link>
    <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&lt;/a&gt;&amp;nbsp;, I already tried with these API. None of them are working. Pls check this below code. I am getting this error.&lt;/P&gt;&lt;PRE&gt;Failed to create subscription. Status Code: 404, Response: {
  "error":{
    "code":"","message":"No HTTP resource was found that matches the request URI}}&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;--Code--&lt;/P&gt;&lt;P&gt;import requests&lt;BR /&gt;import json&lt;/P&gt;&lt;P&gt;# Define constants&lt;BR /&gt;CLIENT_ID = '#######################'&lt;BR /&gt;CLIENT_SECRET = '#######################'&lt;BR /&gt;TENANT_ID = '#######################'&lt;BR /&gt;RESOURCE = '&lt;A href="https://analysis.windows.net/powerbi/api" target="_blank"&gt;https://analysis.windows.net/powerbi/api&lt;/A&gt;'&lt;BR /&gt;API_URL = '&lt;A href="https://api.powerbi.com/v1.0/myorg/groups/{GROUP_ID}/reports/{REPORT_ID}/subscriptions" target="_blank"&gt;https://api.powerbi.com/v1.0/myorg/groups/{GROUP_ID}/reports/{REPORT_ID}/subscriptions&lt;/A&gt;'&lt;/P&gt;&lt;P&gt;def get_access_token():&lt;BR /&gt;url = f'&lt;A href="https://login.microsoftonline.com/{TENANT_ID}/oauth2/v2.0/token" target="_blank"&gt;https://login.microsoftonline.com/{TENANT_ID}/oauth2/v2.0/token&lt;/A&gt;'&lt;BR /&gt;headers = {&lt;BR /&gt;'Content-Type': 'application/x-www-form-urlencoded'&lt;BR /&gt;}&lt;BR /&gt;body = {&lt;BR /&gt;'grant_type': 'client_credentials',&lt;BR /&gt;'client_id': CLIENT_ID,&lt;BR /&gt;'client_secret': CLIENT_SECRET,&lt;BR /&gt;'scope': RESOURCE + '/.default'&lt;BR /&gt;}&lt;BR /&gt;response = requests.post(url, headers=headers, data=body)&lt;BR /&gt;if response.status_code == 200:&lt;BR /&gt;return response.json().get('access_token')&lt;BR /&gt;else:&lt;BR /&gt;print(f"Failed to obtain access token. Status Code: {response.status_code}, Response: {response.text}")&lt;BR /&gt;return None&lt;/P&gt;&lt;P&gt;def create_subscription(access_token, group_id, report_id):&lt;BR /&gt;url = API_URL.format(GROUP_ID=group_id, REPORT_ID=report_id)&lt;BR /&gt;headers = {&lt;BR /&gt;'Authorization': f'Bearer {access_token}',&lt;BR /&gt;'Content-Type': 'application/json'&lt;BR /&gt;}&lt;BR /&gt;data = {&lt;BR /&gt;"displayName": "My Subscription",&lt;BR /&gt;"schedule": {&lt;BR /&gt;"frequency": "Daily",&lt;BR /&gt;"timeZone": "Pacific Standard Time",&lt;BR /&gt;"times": ["07:00"]&lt;BR /&gt;},&lt;BR /&gt;"status": "Enabled"&lt;BR /&gt;}&lt;BR /&gt;response = requests.post(url, headers=headers, json=data)&lt;BR /&gt;if response.status_code == 201:&lt;BR /&gt;print("Subscription created successfully.")&lt;BR /&gt;else:&lt;BR /&gt;print(f"Failed to create subscription. Status Code: {response.status_code}, Response: {response.text}")&lt;/P&gt;&lt;P&gt;if __name__ == "__main__":&lt;BR /&gt;# Replace with your workspace and report IDs&lt;BR /&gt;GROUP_ID = '########################'&lt;BR /&gt;REPORT_ID = '#######################'&lt;/P&gt;&lt;P&gt;token = get_access_token()&lt;BR /&gt;if token:&lt;BR /&gt;create_subscription(token, GROUP_ID, REPORT_ID)&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 16 Sep 2024 11:43:53 GMT</pubDate>
    <dc:creator>shyamganesh</dc:creator>
    <dc:date>2024-09-16T11:43:53Z</dc:date>
    <item>
      <title>API for Subcription</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/API-for-Subcription/m-p/4148903#M55245</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Is there any specific API to set the subcriptions for each reports in power bi. If not means, any ideas to do that through Automation.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Sep 2024 07:15:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/API-for-Subcription/m-p/4148903#M55245</guid>
      <dc:creator>shyamganesh</dc:creator>
      <dc:date>2024-09-13T07:15:53Z</dc:date>
    </item>
    <item>
      <title>Re: API for Subcription</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/API-for-Subcription/m-p/4151533#M55276</link>
      <description>&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;"&gt;Hi, &lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/805767"&gt;@shyamganesh&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;" lang="zh-CN"&gt;In Power BI, you can use the REST API to manage report subscriptions. Here are some relevant API operations:&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial;"&gt;&lt;SPAN&gt;1.&lt;/SPAN&gt;&lt;SPAN&gt;Create Subscription: Use the Add Subscription API to create a new subscription for a specific report.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;" lang="zh-CN"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial;"&gt;&lt;SPAN&gt;2.&lt;/SPAN&gt;&lt;SPAN&gt;Get Subscriptions: Use the Get Subscriptions API to retrieve all subscriptions for a specific report.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;" lang="zh-CN"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial;"&gt;&lt;SPAN&gt;3.&lt;/SPAN&gt;&lt;SPAN&gt;Update Subscription: Use the Update Subscription API to update an existing subscription.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;" lang="zh-CN"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial;"&gt;&lt;SPAN&gt;4.&lt;/SPAN&gt;&lt;SPAN&gt;Delete Subscription: Use the Delete Subscription API to remove a specific subscription.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;" lang="zh-CN"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;" lang="zh-CN"&gt;Here is a screenshot from the relevant documentation:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vlinyulumsft_0-1726451856573.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1167829i678712102AD432AA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="vlinyulumsft_0-1726451856573.png" alt="vlinyulumsft_0-1726451856573.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;" lang="zh-CN"&gt;Here is the link to the relevant documentation:&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;&lt;A href="https://learn.microsoft.com/en-us/rest/api/power-bi-report/subscriptions" target="_blank"&gt;&lt;SPAN&gt;Subscriptions - REST API (Power bi report) | Microsoft Learn&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;&lt;A href="https://learn.microsoft.com/en-us/rest/api/power-bi-report/subscriptions/add-subscription" target="_blank"&gt;&lt;SPAN&gt;Subscriptions - Add Subscription - REST API (Power bi report) | Microsoft Learn&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;&lt;A href="https://learn.microsoft.com/en-us/rest/api/power-bi-report/subscriptions/delete-subscription" target="_blank"&gt;&lt;SPAN&gt;Subscriptions - Delete Subscription - REST API (Power bi report) | Microsoft Learn&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;&lt;A href="https://learn.microsoft.com/en-us/rest/api/power-bi-report/subscriptions/execute-subscription" target="_blank"&gt;&lt;SPAN&gt;Subscriptions - Execute Subscription - REST API (Power bi report) | Microsoft Learn&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;&lt;A href="https://learn.microsoft.com/en-us/rest/api/power-bi-report/subscriptions/get-subscription" target="_blank"&gt;&lt;SPAN&gt;Subscriptions - Get Subscription - REST API (Power bi report) | Microsoft Learn&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;"&gt;Best Regards,&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;"&gt;Leroy Lu&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;"&gt;If this post &lt;SPAN&gt;helps&lt;/SPAN&gt;, then please consider Accept it &lt;SPAN&gt;as the solution &lt;/SPAN&gt;to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Sep 2024 01:57:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/API-for-Subcription/m-p/4151533#M55276</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-09-16T01:57:52Z</dc:date>
    </item>
    <item>
      <title>Re: API for Subcription</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/API-for-Subcription/m-p/4152321#M55287</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&lt;/a&gt;&amp;nbsp;, I already tried with these API. None of them are working. Pls check this below code. I am getting this error.&lt;/P&gt;&lt;PRE&gt;Failed to create subscription. Status Code: 404, Response: {
  "error":{
    "code":"","message":"No HTTP resource was found that matches the request URI}}&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;--Code--&lt;/P&gt;&lt;P&gt;import requests&lt;BR /&gt;import json&lt;/P&gt;&lt;P&gt;# Define constants&lt;BR /&gt;CLIENT_ID = '#######################'&lt;BR /&gt;CLIENT_SECRET = '#######################'&lt;BR /&gt;TENANT_ID = '#######################'&lt;BR /&gt;RESOURCE = '&lt;A href="https://analysis.windows.net/powerbi/api" target="_blank"&gt;https://analysis.windows.net/powerbi/api&lt;/A&gt;'&lt;BR /&gt;API_URL = '&lt;A href="https://api.powerbi.com/v1.0/myorg/groups/{GROUP_ID}/reports/{REPORT_ID}/subscriptions" target="_blank"&gt;https://api.powerbi.com/v1.0/myorg/groups/{GROUP_ID}/reports/{REPORT_ID}/subscriptions&lt;/A&gt;'&lt;/P&gt;&lt;P&gt;def get_access_token():&lt;BR /&gt;url = f'&lt;A href="https://login.microsoftonline.com/{TENANT_ID}/oauth2/v2.0/token" target="_blank"&gt;https://login.microsoftonline.com/{TENANT_ID}/oauth2/v2.0/token&lt;/A&gt;'&lt;BR /&gt;headers = {&lt;BR /&gt;'Content-Type': 'application/x-www-form-urlencoded'&lt;BR /&gt;}&lt;BR /&gt;body = {&lt;BR /&gt;'grant_type': 'client_credentials',&lt;BR /&gt;'client_id': CLIENT_ID,&lt;BR /&gt;'client_secret': CLIENT_SECRET,&lt;BR /&gt;'scope': RESOURCE + '/.default'&lt;BR /&gt;}&lt;BR /&gt;response = requests.post(url, headers=headers, data=body)&lt;BR /&gt;if response.status_code == 200:&lt;BR /&gt;return response.json().get('access_token')&lt;BR /&gt;else:&lt;BR /&gt;print(f"Failed to obtain access token. Status Code: {response.status_code}, Response: {response.text}")&lt;BR /&gt;return None&lt;/P&gt;&lt;P&gt;def create_subscription(access_token, group_id, report_id):&lt;BR /&gt;url = API_URL.format(GROUP_ID=group_id, REPORT_ID=report_id)&lt;BR /&gt;headers = {&lt;BR /&gt;'Authorization': f'Bearer {access_token}',&lt;BR /&gt;'Content-Type': 'application/json'&lt;BR /&gt;}&lt;BR /&gt;data = {&lt;BR /&gt;"displayName": "My Subscription",&lt;BR /&gt;"schedule": {&lt;BR /&gt;"frequency": "Daily",&lt;BR /&gt;"timeZone": "Pacific Standard Time",&lt;BR /&gt;"times": ["07:00"]&lt;BR /&gt;},&lt;BR /&gt;"status": "Enabled"&lt;BR /&gt;}&lt;BR /&gt;response = requests.post(url, headers=headers, json=data)&lt;BR /&gt;if response.status_code == 201:&lt;BR /&gt;print("Subscription created successfully.")&lt;BR /&gt;else:&lt;BR /&gt;print(f"Failed to create subscription. Status Code: {response.status_code}, Response: {response.text}")&lt;/P&gt;&lt;P&gt;if __name__ == "__main__":&lt;BR /&gt;# Replace with your workspace and report IDs&lt;BR /&gt;GROUP_ID = '########################'&lt;BR /&gt;REPORT_ID = '#######################'&lt;/P&gt;&lt;P&gt;token = get_access_token()&lt;BR /&gt;if token:&lt;BR /&gt;create_subscription(token, GROUP_ID, REPORT_ID)&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Sep 2024 11:43:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/API-for-Subcription/m-p/4152321#M55287</guid>
      <dc:creator>shyamganesh</dc:creator>
      <dc:date>2024-09-16T11:43:53Z</dc:date>
    </item>
    <item>
      <title>Re: API for Subcription</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/API-for-Subcription/m-p/4156257#M55343</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/805767"&gt;@shyamganesh&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your swift response. I appreciate the effort you have put into addressing this issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, I may not have explained clearly. The API I provided pertains to the report subscription API for Power BI Report Server. Based on the code you shared, I suspect you might be looking for the report subscription API for Power BI Service.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can try using Power Automate to automate the creation and sending of emails,there are still some limitations to this method, and you can choose according to your needs:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1.Firstly, sign in to Power Automate and create a new flow. Choose an appropriate trigger, such as “When a new item is created” in a SharePoint list or “When an email arrives” in Outlook.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2,Next, add the necessary actions to your flow. For instance, you can use the “Send an email” action to automate the email sending process. You can also include conditions to check specific criteria before sending the email.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;3.&lt;/SPAN&gt;&lt;SPAN&gt;Finally, test your flow to ensure it works as expected, then save and activate it.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vlinyulumsft_0-1726649838650.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1169232i6C07A4A2892CB758/image-size/medium?v=v2&amp;amp;px=400" role="button" title="vlinyulumsft_0-1726649838650.png" alt="vlinyulumsft_0-1726649838650.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For detailed guidance, please refer to the official documentation.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/power-automate/email-top-scenarios" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;Create flows for popular email scenarios in Power Automate - Power Automate | Microsoft Learn&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think your idea of having an API to automate the creation of service subscriptions is fantastic.If you feel that performance needs to be improved, you can also submit an idea on&lt;/P&gt;
&lt;P&gt;&lt;A href="https://ideas.fabric.microsoft.com/" target="_blank" rel="noopener"&gt;https://ideas.fabric.microsoft.com/&lt;/A&gt; and wait for users with the same needs as you to vote for you and help you realize the idea as soon as possible. Many features of our current products are designed and upgraded bed on customers’ feedback.&amp;nbsp; With requirements like this increase, the problem may well be released in the future.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for your understanding.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Leroy Lu&lt;/P&gt;
&lt;P&gt;If this post &lt;STRONG&gt;&lt;I&gt;helps&lt;/I&gt;&lt;/STRONG&gt;, then please consider Accept it &lt;STRONG&gt;&lt;I&gt;as the solution &lt;/I&gt;&lt;/STRONG&gt;to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Sep 2024 09:02:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/API-for-Subcription/m-p/4156257#M55343</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-09-18T09:02:35Z</dc:date>
    </item>
  </channel>
</rss>

