Forum Discussion
Getting Token for API Dataflow Gateway Binding
- 4 years ago
You are correct, that API call is not exposed. Please vote for the idea.
- 3 years ago
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.
- Get the Application ID from the call by monitor the network traffic while logging into Power BI using the Powershell cmdlets.
- AuthUrl = "https://login.windows.net{tenant identifier}"
- ResourceUrl ="https://analysis.windows.net/powerbi/api'
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
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.
- KDM_HOSS4 years agoAdvocate I
Getting an access token works fine.
Using the token works fine for the Power BI REST API.
Using the token to run the API that binds dataflows to gateways doesn't work.
The gateway binding API will work if I use the token that PBI Online is using.
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.