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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Grooby
Frequent Visitor

Search All Datasets by Gateway Connection

Is there a way to search for all Power BI Datasets using a specifc Gateway Connection?  REST API?  

3 REPLIES 3
aybarsacar
Frequent Visitor

The answer provided is wrong as the JSON response returned does not have "gateway_id".

Please refer to documentation Datasets - Get Datasets - REST API (Power BI Power BI REST APIs) | Microsoft Learn

 

The response object from a single dataset returns the "gateway_id" but not the Get Datasets in a List. 

jaweher899
Super User
Super User

Yes, you can use the Power BI REST API to search for all Power BI datasets using a specific gateway connection. Here's how:

  1. Get the ID of the gateway connection you want to search for. You can do this by going to the Power BI service, clicking on the gear icon in the top right corner, selecting "Manage gateways," and then selecting the gateway you're interested in. The ID will be listed in the URL of the gateway page.

  2. Use the Power BI REST API to get a list of all datasets in your organization. You can do this by sending a GET request to the following URL: https://api.powerbi.com/v1.0/myorg/datasets. You will need to provide an access token in the Authorization header of the request. You can get an access token using the steps outlined in the Power BI REST API documentation.

  3. Loop through the list of datasets returned by the API and check the gatewayConnectionId property of each dataset. If the gatewayConnectionId matches the ID of the gateway you're interested in, then that dataset is using the specified gateway.

Here's an example in Python using the requests library:

import requests

# Replace with your own values
gateway_id = "my-gateway-id"
access_token = "my-access-token"

# Get list of all datasets
url = "https://api.powerbi.com/v1.0/myorg/datasets"
headers = {"Authorization": f"Bearer {access_token}"}
response = requests.get(url, headers=headers)
datasets = response.json()["value"]

# Filter datasets by gateway ID
datasets_using_gateway = [d for d in datasets if d["gatewayConnectionId"] == gateway_id]

# Print list of dataset names
for dataset in datasets_using_gateway:
print(dataset["name"])

 

This code will print a list of all dataset names that are using the specified gateway. You can modify the code to perform different actions based on the list of datasets returned.

Thank you so much for your quick response.  I do have a follow up question.  I do not see the the GatewayConnectionID in the URL, nor do i see this attribute on any of the RestAPI's.  Is there another method of obtaining this value?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors