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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
KDM_HOSS
Frequent Visitor

Getting Token for API Dataflow Gateway Binding

I'm attempting to use the https://wabi-canada-central-redirect.analysis.windows.net/metadata/dataflows/settings/{dataflow GUID... API, but I'm having issues with the access token. I can make the API work if I get the token from any of the API that's ran on PBI Online using Chrome's network Developer Tool and also using the access token from Powershell cmdlet Get-PowerBIAccessToken.

 

I'm unable to use an OAuth2 access token for an application already registered on AzureAD. I keep getting a 401 Unauthorized. I'm missing somthing, but I don't know what. I could be missing a scope possibly?

 

I'm currently doing testing using Postman.

 

I can provide more infomation if needed. Just let me know.

Any help would be greatly appreciated.

 

2 ACCEPTED SOLUTIONS

You are correct, that API call is not exposed. Please vote for the idea.

 

Microsoft Idea (powerbi.com)

 

View solution in original post

KDM_HOSS
Frequent Visitor

Update

The API works. I've been using the API for over a year to handle automated dataflow gateway binding in various applications.

 

Rough Outline

To get the access token to use for the API you'll need a couple things to get it through the Microsoft.Identity.Client.

Run API

  • Add an AuthenticationHeader to a HttpClient containing the access token.
  • Get the URL Base API path from monitoring network traffic when binding a dataflow to a gateway in PBI Online
  • URL will be "{Url base path}/metadata/dataflows/settings/{dataflow.ObjectId}/bind"
  • Content will be a json formatted string with Gateway ID
    • "{{""gatewayObjectId"":""{gateway.Id}""}}"
  • Post

View solution in original post

8 REPLIES 8
KDM_HOSS
Frequent Visitor

Update

The API works. I've been using the API for over a year to handle automated dataflow gateway binding in various applications.

 

Rough Outline

To get the access token to use for the API you'll need a couple things to get it through the Microsoft.Identity.Client.

Run API

  • Add an AuthenticationHeader to a HttpClient containing the access token.
  • Get the URL Base API path from monitoring network traffic when binding a dataflow to a gateway in PBI Online
  • URL will be "{Url base path}/metadata/dataflows/settings/{dataflow.ObjectId}/bind"
  • Content will be a json formatted string with Gateway ID
    • "{{""gatewayObjectId"":""{gateway.Id}""}}"
  • Post
KDM_HOSS
Frequent Visitor

I should note that I created a .NET app that manages various aspects of Power BI. I'm using the token from Get-PowerBIAccessToken Powershell cmdlet, using my credentials, to run the dataflow gateway binding API. It works fine for me. If another user uses the gateway binding functionality for dataflows that they cloned, it doesn't work, presumibly because the token is for my user and the dataflow owner is the app user.

 

My goal is to ditch the Powershell script and move the token generation into the application so any user can use the "hidden" Power BI REST API.

lbendlin
Super User
Super User

Apart from the URL being iffy (you should really be using the standard REST API URL) this usually works. Which auth method did you specify? client_credentials, password, something else?

I'm using grant_type = password for the authentication.

The standard REST API URL doesn't have/expose the dataflow gateway binding functionality, which is why I'm having to use "https://wabi-canada-central-redirect.analysis.windows.net".

I found the URL while looking at the REST API that Power BI Online was running.

Tenant is located in canada, hence the URL.

Please use the standard URL and the standard authentication method (OAUTH2 -> bearer token). I highly doubt it will let you authentiate via password.

Getting an access token works fine.

KDM_HOSS_0-1645470567050.png

 

Using the token works fine for the Power BI REST API.

KDM_HOSS_1-1645470765310.png

 

Using the token to run the API that binds dataflows to gateways doesn't work.

KDM_HOSS_2-1645470957702.pngKDM_HOSS_3-1645470985298.png

 

The gateway binding API will work if I use the token that PBI Online is using.

KDM_HOSS_8-1645472126485.png

 

KDM_HOSS_5-1645471356699.pngKDM_HOSS_6-1645471584299.png

 

I'd love to use the standard request URL for dataflow gateway binding, but it doesn't exists. Happy to be wrong about that, though.

I should note that the Powershell cmdlet Get-PowerBIAccessToken generates a token that works with the dataflow gateway binding API.

KDM_HOSS_7-1645471912873.png

 

You are correct, that API call is not exposed. Please vote for the idea.

 

Microsoft Idea (powerbi.com)

 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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