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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Christ-M
Helper I
Helper I

Get data in a dataset

Hello,

I want to retrieve the contents of my dataset_ID.


Through this link https://learn.microsoft.com/fr-en/rest/api/power-bi/datasets/get-dataset-in-group, I was able to obtain the group_id and the dataset_id using the following query:

GET https://learn.microsoft.com/en-us/rest/api/power-bi/datasets/get-dataset-in-group
Now, I would like to retrieve the contents of each dataset_ID.


How to proceed? I would need help with this.

Thank you in advance for your assistance.

1 ACCEPTED SOLUTION

Hi  @Christ-M ,

As you are facing a 404 error while retrieving tables please check these troubleshooting steps:

1) The Service principal is still active in AAD and Access token is getting generated via the Service principle.
2) Double-check that all the variable IDs you have entered, such as tenant_id, dataset_id are accurate and correctly formatted.

3) Try your API call from third party tool such as postman once to confirm everything works correctly.

Thanks and Regards

View solution in original post

7 REPLIES 7
v-nmadadi-msft
Community Support
Community Support

Hi @Christ-M ,
We are following up once again regarding your query. Could you please confirm if the issue has been resolved?

If the issue has been resolved, we kindly request you to share the resolution or key insights here to help others in the community. If we don’t hear back, we’ll go ahead and close this thread.

Should you need further assistance in the future, we encourage you to reach out via the Microsoft Fabric Community Forum and create a new thread or reopen this thread. We’ll be happy to help.

 

Thank you for your understanding and participation.

Christ-M
Helper I
Helper I

Thank you for your answers, @freginier 

 

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

Hello, 

 

I am really not sure then. 

 

Sorry I couldn't help more 😅

Christ-M
Helper I
Helper I

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 ,

As you are facing a 404 error while retrieving tables please check these troubleshooting steps:

1) The Service principal is still active in AAD and Access token is getting generated via the Service principle.
2) Double-check that all the variable IDs you have entered, such as tenant_id, dataset_id are accurate and correctly formatted.

3) Try your API call from third party tool such as postman once to confirm everything works correctly.

Thanks and Regards

Christ-M
Helper I
Helper I

@freginier 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.?

freginier
Solution Sage
Solution Sage

Hey there!

 

Please try these steps to get your solution: 

1. Use the Power BI API to Retrieve Tables in a Dataset

API Endpoint: GET https://api.powerbi.com/v1.0/myorg/groups/{group_id}/datasets/{dataset_id}/tables 

(This returns the list of tables in the dataset.)

 

2. Retrieve Table Rows (Dataset Contents)

Once you have the table names, you can fetch the rows using:

API Endpoint:GET https://api.powerbi.com/v1.0/myorg/groups/{group_id}/datasets/{dataset_id}/tables/{table_name}/rows 

(This returns all rows in a specific table of the dataset.) 

 

3. 

Make sure your API call includes an authorization token. You need:

Power BI API Permissions: Dataset.Read.All , Dataset.ReadWrite.All
You must authenticate using OAuth 2.0 via Azure Active Directory (AAD).

How to Authenticate:

- Register an Azure AD App for Power BI.
- Get an OAuth token.
- Use the token in your API request headers: Authorization: Bearer {access_token}

 

Hope this helps!

😁😁

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.