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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Laurene
Frequent Visitor

Automatically fetch visuals links in a dashboard + download visuals as images

Hello everyone,
I'm currently working on a project where I need to link a dashboard to word and powerpoint. The goal is that everytime the dashboard is updated, the modifications are automatically transfered to the powerpoint and word reports. I can add links to each power bi visuals to my powerpoint with the ppt add-in, but I have two problems:
  1. I cannot do the same for word. Apparently there are no add-ins for word like there is for ppt. So if there are no solutions to link pbi visuals to word, is it possible to automatically download the pbi visuals as images?
  2. I need to fetch the link to each visual in my dashboards automatically (and maybe put them in an excel), is it possible to do that? Maybe with the pbi api or a python script?
Thank you in advance for your help,
Best Regards,
Laurene
2 ACCEPTED SOLUTIONS
Sahir_Maharaj
Super User
Super User

Hello @Laurene,

 

1. You can use Power Automate to export Power BI reports to Word documents as PDFs, but this may not allow you to update visuals dynamically. (Another approach would be to embed Power BI reports in a Word document using live links)

 

2. A Python script can be used in conjunction with the Power BI REST API to download the images.

import requests
from requests.auth import HTTPBasicAuth

# Replace with your credentials and Power BI API details
CLIENT_ID = 'your-client-id'
CLIENT_SECRET = 'your-client-secret'
TENANT_ID = 'your-tenant-id'
WORKSPACE_ID = 'your-workspace-id'
REPORT_ID = 'your-report-id'
VISUAL_ID = 'your-visual-id'
API_ENDPOINT = f'https://api.powerbi.com/v1.0/myorg/groups/{WORKSPACE_ID}/reports/{REPORT_ID}/exportToFile'

# Authentication
auth_url = f"https://login.microsoftonline.com/{TENANT_ID}/oauth2/v2.0/token"
auth_params = {
    'grant_type': 'client_credentials',
    'client_id': CLIENT_ID,
    'client_secret': CLIENT_SECRET,
    'scope': 'https://graph.microsoft.com/.default'
}
auth_response = requests.post(auth_url, data=auth_params)
access_token = auth_response.json().get('access_token')

# Requesting visual as an image
headers = {
    'Authorization': f'Bearer {access_token}'
}
response = requests.get(API_ENDPOINT, headers=headers)

if response.status_code == 200:
    with open(f"{VISUAL_ID}.png", 'wb') as f:
        f.write(response.content)
    print(f"Visual {VISUAL_ID} downloaded as an image.")
else:
    print(f"Failed to download visual. Status code: {response.status_code}")

Hope this helps.


Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

View solution in original post

Your solution is so great @Sahir_Maharaj 

Hi, @Laurene 

You can call Power BI's API interface from the tutorial below to export your report to a file.
As you mentioned, there are a few programming languages that you can do that. Super user gives a good sample code.

Export Power BI embedded analytics reports API - Power BI | Microsoft Learn

vjianpengmsft_0-1722923713084.png

vjianpengmsft_1-1722923737956.png

If you want to get the ID in visual, here there are two official ways to do it:

vjianpengmsft_2-1722923880125.png

In addition, you can also check out the following community cases with the same problem, in which there is also a way to get the visual ID:

Solved: identifying visualname in Custom Visuals - Microsoft Fabric Community

vjianpengmsft_3-1722923981961.png

vjianpengmsft_4-1722923992287.png

 

Best Regards

Jianpeng Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

View solution in original post

4 REPLIES 4
Sahir_Maharaj
Super User
Super User

Hello @Laurene,

 

1. You can use Power Automate to export Power BI reports to Word documents as PDFs, but this may not allow you to update visuals dynamically. (Another approach would be to embed Power BI reports in a Word document using live links)

 

2. A Python script can be used in conjunction with the Power BI REST API to download the images.

import requests
from requests.auth import HTTPBasicAuth

# Replace with your credentials and Power BI API details
CLIENT_ID = 'your-client-id'
CLIENT_SECRET = 'your-client-secret'
TENANT_ID = 'your-tenant-id'
WORKSPACE_ID = 'your-workspace-id'
REPORT_ID = 'your-report-id'
VISUAL_ID = 'your-visual-id'
API_ENDPOINT = f'https://api.powerbi.com/v1.0/myorg/groups/{WORKSPACE_ID}/reports/{REPORT_ID}/exportToFile'

# Authentication
auth_url = f"https://login.microsoftonline.com/{TENANT_ID}/oauth2/v2.0/token"
auth_params = {
    'grant_type': 'client_credentials',
    'client_id': CLIENT_ID,
    'client_secret': CLIENT_SECRET,
    'scope': 'https://graph.microsoft.com/.default'
}
auth_response = requests.post(auth_url, data=auth_params)
access_token = auth_response.json().get('access_token')

# Requesting visual as an image
headers = {
    'Authorization': f'Bearer {access_token}'
}
response = requests.get(API_ENDPOINT, headers=headers)

if response.status_code == 200:
    with open(f"{VISUAL_ID}.png", 'wb') as f:
        f.write(response.content)
    print(f"Visual {VISUAL_ID} downloaded as an image.")
else:
    print(f"Failed to download visual. Status code: {response.status_code}")

Hope this helps.


Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

Hello,

Thank you very much for your help and your answer! How can I know the visuals id though? My goal is ultimately to automatically fetch the visuals links, so having to manually get the ids kind of defeats the purpose. 

Thank you!

Laurene

Your solution is so great @Sahir_Maharaj 

Hi, @Laurene 

You can call Power BI's API interface from the tutorial below to export your report to a file.
As you mentioned, there are a few programming languages that you can do that. Super user gives a good sample code.

Export Power BI embedded analytics reports API - Power BI | Microsoft Learn

vjianpengmsft_0-1722923713084.png

vjianpengmsft_1-1722923737956.png

If you want to get the ID in visual, here there are two official ways to do it:

vjianpengmsft_2-1722923880125.png

In addition, you can also check out the following community cases with the same problem, in which there is also a way to get the visual ID:

Solved: identifying visualname in Custom Visuals - Microsoft Fabric Community

vjianpengmsft_3-1722923981961.png

vjianpengmsft_4-1722923992287.png

 

Best Regards

Jianpeng Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

Thank you very much for your help @v-jianpeng-msft @Sahir_Maharaj !

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.