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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
manishchauhan16
New Member

Trying to get visual ID to export data through python

I an unable to get visual ID from the pages :

# -*- coding: utf-8 -*-
"""
Created on Tue Sep 12 00:13:23 2023

@author: MAnish Chauhan | +91-(9774083186) | 
"""

# Importing Pacakages
import requests
import msal
import pprint
# Defining the variables
# app id - Client ID from Azure application
app_id='-'
# Tenant Id - ID from the azure application
tenant_id = '-'
# auth_url - Default Value with dynamic tenant
auth_url = 'https://login.microsoftonline.com/' + tenant_id
# scope - default value
scope = ['https://analysis.windows.net/powerbi/api/.default']

# Azure application secret code value
client_secret='-'


# User credentials
username = '-' # Replace with your username
password = '-' # Replace with your password

# Getting the access token using username and password
app = msal.PublicClientApplication(app_id, authority=auth_url)
result = app.acquire_token_by_username_password(username, password, scopes=scope)
# Checkpoint
#print(response)
access_token=response.get('access_token')
#print(access_token)

report_id='b31696d7-5e7d-4a3e-80b8-f96d633da8db'
workspace_id='*****************************************'

#endpoint- API endpoint for the service which needs to be accesssed
endpoint="https://api.powerbi.com/v1.0/myorg/groups/*********************/reports/*******************/pages/Re..."
#endpoint= 'https://api.powerbi.com/v1.0/myorg/groups/'+Workspace_ID+'/dashboards'
#endpoint= 'https://api.powerbi.com/v1.0/myorg/groups/'+Workspace_ID+'/datasets/cab13d40-d7df-4296-8d00-8affd86b...'
#Headers for authorization

 

The code works fine until given end point , however I am not able to get endpoint which gives me the visual ID
headers={
'Authorization': 'Bearer '+access_token
}
response_dataset=requests.get(endpoint, headers=headers)
#print(response_dataset)
#pprint.pprint(response_dataset.json())
print(response_dataset.status_code)

3 REPLIES 3
lbendlin
Super User
Super User

Use the embedded playground to retrieve the visual ID.

 

Once you have it, what do you plan to do with it?

Spoiler
 

Thanks for suggesting , i will try that. Post getting the visual id , plan is to somehow export data of the visual through python.

You can use the "Export to PNG" API call. 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors