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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Christ-M
Helper I
Helper I

Get the content of a dataset in group

Hello, I would like to retrieve the contents of my dataset_ID. Using this link https://learn.microsoft.com/en-en/rest/api/power-bi/datasets/get-dataset-in-group I was able to obtain the group_id and the dataset_id through the following query: GET https://api.powerbi.com/v1.0/myorg/groups/{groupId}/datasets/{datasetId}Now, I would like to retrieve the contents of each ID_dataset. How do I proceed? I would need help for this.

Thank you in advance for your help.

7 REPLIES 7
Christ-M
Helper I
Helper I

Hello, I would like to retrieve the contents of my dataset_ID. Using this link https://learn.microsoft.com/en-en/rest/api/power-bi/datasets/get-dataset-in-group I was able to obtain the group_id and the dataset_id through the following query: GET https://api.powerbi.com/v1.0/myorg/groups/{groupId}/datasets/{datasetId}Now, I would like to retrieve the contents of each ID_dataset. How do I proceed? I would need help for this.

Thank you in advance for your help.

I would like to retrieve the contents of each ID_dataset

datasets (Semantic Models) contain tables and partitions.  Please be more specific in what you are trying to retrieve.  It will also help if you can indicate what you plan to do after the retrieval.

@lbendlin 

I want to retrieve the tables and their contents, then send them to a database.

I allow to put my basic code here acr I’m looking for a solution .

 

 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_headers = {"Content-Type": "application/x-www-form-urlencoded"}
    auth_data = {
        "grant_type": "client_credentials",
        "client_id": client_id,
        "client_secret": client_secret,
    }
 
    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):
    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_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.?

Hi @Christ-M,

>>Error 404, message: Dataset xxxxx is not Push API dataset, and it leaves me table retrieval error. 

The error message mention the dataset xxx is not a push dataset so you can't use push dataset related rest api to operate on it.

I'd like to suggest you check their types to confirm these:

Real-time streaming in Power BI - Power BI | Microsoft Learn

Creating real-time dashboards in Power BI with push datasets - SQLBI

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

@v-shex-msft @lbendlin Finally, there is no API to extract the semantic data that are not push APIs. It’s a bit unfortunate that this question is not well detaille with a clear answer. 

 

I was able to go to the source of the data, but the problem is that the data of the root have undergone treatments, I just want to recover the processed data. I have hundreds of power bi reports and I need to solve this problem.

Finally, there is no API to extract the semantic data that are not push APIs.

That is incorrect.  You can run DAX queries against the semantic model, including simple EVALUATE queries.

 

However, trying to "extract all data from a cube"  is similar to "create a flat table from a multi level JSON or XML".  It's just not possible because there is a clear difference between a multidimensional object and a simple flat table.  You cannot convert one into the other without loss of detail.

Christ-M
Helper I
Helper I

Hello, I would like to retrieve the contents of my dataset_ID. Using this link https://learn.microsoft.com/en-en/rest/api/power-bi/datasets/get-dataset-in-group I was able to obtain the group_id and the dataset_id through the following query: GET https://api.powerbi.com/v1.0/myorg/groups/{groupId}/datasets/{datasetId}Now, I would like to retrieve the contents of each ID_dataset. How do I proceed? I would need help for this.

Thank you in advance for your help.

Helpful resources

Announcements