Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more
Here is my code but I can’t recover the tables, how to get it done
import requests
# Remplacez par vos informations spécifiques
client_id = "your_client_id"
client_secret = "your_client_secret"
tenant_id = "your_tenant_id"
dataset_id = "your_dataset_id"
workspace_id = "your_workspace_id"
# Étape 1 : Obtenir un jeton d'accès via OAuth2
def get_access_token():
auth_url = f"https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token"
auth_headers = {"Content-Type": "application/x-www-form-urlencoded"}
auth_data = {
"grant_type": "client_credentials",
"client_id": client_id,
"client_secret": client_secret,
"scope": "https://analysis.windows.net/powerbi/api/.default",
}
response = requests.post(auth_url, headers=auth_headers, data=auth_data)
response.raise_for_status() # Génère une exception si une erreur survient
return response.json().get("access_token")
# Étape 2 : Lister les tables du dataset
def list_tables(access_token, workspace_id, dataset_id):
url = f"https://api.powerbi.com/v1.0/myorg/groups/{workspace_id}/datasets/{dataset_id}/tables"
headers = {"Authorization": f"Bearer {access_token}"}
response = requests.get(url, headers=headers)
response.raise_for_status()
return response.json()
# Étape 3 : Exécuter une requête DAX pour extraire les données d'une table
def query_table_data(access_token, workspace_id, dataset_id, table_name):
query_url = f"https://api.powerbi.com/v1.0/myorg/groups/{workspace_id}/datasets/{dataset_id}/executeQueries"
query_headers = {
"Authorization": f"Bearer {access_token}",
"Content-Type": "application/json",
}
query_data = {
"queries": [
{
"query": f"EVALUATE {table_name}" # Requête DAX pour obtenir toutes les données de la table
}
]
}
response = requests.post(query_url, headers=query_headers, json=query_data)
response.raise_for_status()
return response.json()
# Étape 4 : Extraire les données de toutes les tables
def extract_all_data():
try:
# Obtenir le token d'accès
access_token = get_access_token()
print("Jeton d'accès obtenu avec succès.")
# Lister les tables
tables_info = list_tables(access_token, workspace_id, dataset_id)
tables = tables_info.get("value", [])
if not tables:
print("Aucune table trouvée dans le dataset.")
return
print(f"Tables trouvées : {[table['name'] for table in tables]}")
# Parcourir chaque table et extraire les données
for table in tables:
table_name = table["name"]
print(f"Extraction des données pour la table : {table_name}")
data = query_table_data(access_token, workspace_id, dataset_id, table_name)
if "results" in data:
rows = data["results"][0]["tables"][0]["rows"]
print(f"Données de la table {table_name} : {rows}")
else:
print(f"Aucune donnée trouvée pour la table {table_name}")
except requests.exceptions.RequestException as e:
print(f"Erreur réseau ou API : {e}")
except Exception as e:
print(f"Erreur : {e}")
if __name__ == "__main__":
extract_all_data()
1. I receive an error when retrieving tables: Error 404, message: Dataset xxxxx is not Push API dataset, and it leaves me table retrieval error.
2. What solutions I can do or even how to change my code to get the tables and their content.?
3. If I want to use the Endpoint XMLA, how can I use it? What documentation should I turn to for Using XMLA ?
4. Is there a solution to my problem? how to correct the message Dataset is not Push API dataset.?
Solved! Go to Solution.
My question is how to retrieve data from a table when it’s not a push API.
You run a DAX query against the semantic model
EVALUATE table
Hi @Christ-M,
May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.
Thank you.
Hello @v-nmadadi-msft my problem is remains without a precise answer. The proposed tracks do not work.
Hi @Christ-M ,
By default, Premium capacity or Premium Per User semantic model workloads have the XMLA endpoint property setting enabled for read-only. This means applications can only query a semantic model. For applications to perform write operations, the XMLA Endpoint property must be enabled for read-write. If any write operations are being performed please consider switching on the Read-write
For more details on how to:
Semantic model connectivity and management with the XMLA endpoint in Power BI - Power BI | Microsoft...
If you find this post helpful, please mark it as an "Accept as Solution" and consider giving a KUDOS.
Thanks and Regards
Thank you for your answers, @v-nmadadi-msft and @lbendlin
it does not correspond to my need.
My question is how to retrieve data from a table when it’s not a push API.
Can I have a request that shows how to do it or a code that shows how to do it?
Thank you for your contribution
My question is how to retrieve data from a table when it’s not a push API.
You run a DAX query against the semantic model
EVALUATE table
Hi @Christ-M ,
Thanks for reaching out to the Microsoft fabric community forum.
The following semantic models aren't accessible by using the XMLA endpoint. These semantic models won't appear under the workspace in SSMS or in other tools:
1) Semantic models based on a live connection to an Azure Analysis Services or SQL Server Analysis Services model.
2) Semantic models based on a live connection to a Power BI semantic model in another workspace. To learn more, see Intro to semantic models across workspaces.
3) Semantic models with Push data by using the REST API.
4) Semantic models in My Workspace.
5) Excel workbook semantic models.
Reference: Semantic model connectivity and management with the XMLA endpoint in Power BI - Power BI | Microsoft...
Please make sure the semantic model you are trying to connect does not fall under the above criteria.
If you find this post helpful, please mark it as an "Accept as Solution" and consider giving a KUDOS.
Thanks and Regards
1. You need to run DMV queries to enumerate the tables and partitions in a semantic model
2. same
3. Run DMV queries
4. same
Check out the April 2025 Power BI update to learn about new features.
Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.
User | Count |
---|---|
48 | |
28 | |
21 | |
19 | |
13 |