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

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

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
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.