<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Gateway Binding using the API in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Gateway-Binding-using-the-API/m-p/2614767#M37133</link>
    <description>&lt;P&gt;I tried the suggestions in that post, but no luck.&lt;/P&gt;</description>
    <pubDate>Fri, 01 Jul 2022 18:07:54 GMT</pubDate>
    <dc:creator>bmtolleson</dc:creator>
    <dc:date>2022-07-01T18:07:54Z</dc:date>
    <item>
      <title>Gateway Binding using the API</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Gateway-Binding-using-the-API/m-p/2604963#M37017</link>
      <description>&lt;P&gt;I get an Error 400 (Bad Request) using the code below.&amp;nbsp; I have looked at it for hours.&amp;nbsp; Does anyone see anything wrong?&amp;nbsp; Any suggestions?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#Login to Power BI using PowerBIPS App registration.&lt;BR /&gt;Write-Host "Start Login"&lt;BR /&gt;$ApplicationId = "abc123"&lt;BR /&gt;$SecurePassword = "password" | ConvertTo-SecureString -AsPlainText -force&lt;BR /&gt;$credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $ApplicationId, $SecurePassword&lt;BR /&gt;Connect-PowerBIServiceAccount -ServicePrincipal -Credential $credential -TenantId "ten123"&lt;BR /&gt;Write-Host "Login Success"&lt;/P&gt;&lt;P&gt;Write-Host "Get Workspace info for workspace: AC Common_TST"&lt;BR /&gt;$workspaceName = "AC Common_TST"&lt;BR /&gt;$datasetName = "DateDim"&lt;BR /&gt;$workspace = Get-PowerBIWorkspace -Name $workspaceName&lt;BR /&gt;$workspaceObject = ( Get-PowerBIWorkspace -Name "AC Common_TST" )&lt;BR /&gt;$groupid=$workspaceObject.id&lt;BR /&gt;$newGatewayId = "gatewayid" # the ID of PRDGateway1&lt;BR /&gt;$dataset = Get-PowerBIDataset -WorkspaceId $workspace.Id | Where-Object Name -eq $datasetName&lt;BR /&gt;$datasetid = $dataset.id&lt;BR /&gt;$workspaceId = $workspace.Id&lt;/P&gt;&lt;P&gt;Write-Host "GroupID is "$workspace.id&lt;BR /&gt;Write-Host "Dataset ID is "$dataset.id&lt;/P&gt;&lt;P&gt;# POST body&lt;BR /&gt;$postParams = @'&lt;BR /&gt;{&lt;BR /&gt;"gatewayObjectId": "gatewayid",&lt;BR /&gt;"datasourceObjectIds": [&lt;BR /&gt;"dsid"&lt;BR /&gt;]&lt;BR /&gt;}&lt;BR /&gt;'@&lt;BR /&gt;$jsonPostBody = $postParams | ConvertTo-JSON&lt;/P&gt;&lt;P&gt;$uri = "&lt;A href="https://api.powerbi.com/v1.0/myorg/groups/$workspaceid/datasets/$datasetId/Default.BindToGateway" target="_blank" rel="noopener"&gt;https://api.powerbi.com/v1.0/myorg/groups/$workspaceid/datasets/$datasetId/Default.BindToGateway&lt;/A&gt;"&lt;/P&gt;&lt;P&gt;Invoke-PowerBIRestMethod -URL $uri -Method POST -Body $jsonPostBody&lt;BR /&gt;Resolve-PowerBIError -Last&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jun 2022 18:57:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Gateway-Binding-using-the-API/m-p/2604963#M37017</guid>
      <dc:creator>bmtolleson</dc:creator>
      <dc:date>2022-06-27T18:57:18Z</dc:date>
    </item>
    <item>
      <title>Re: Gateway Binding using the API</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Gateway-Binding-using-the-API/m-p/2611373#M37102</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/406162"&gt;@bmtolleson&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;The following ones are the threads which have the similar problem as yours, please check their solution. Hope they can also help solve your problem.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/Developer/BindToGateway-Powershell-REST-API-POST-failing-Need-Help/m-p/852851" target="_self"&gt;&lt;SPAN&gt;BindToGateway Powershell REST API POST failing&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;I have found the reasons why this wasnt working so thought I would list them here for future users. To get this to work there are a few things to be aware of:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. If the datasource is not assigned to a gateway you need to not include the datasource ID values (you wont actually be able to get these ID values if it is unassigned). I assume the ability to specify the data source id values is only relevent when the dataset is already assigned to a gateway, but I dont know if you can use two separate gateways for one dataset with two datasources.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. Service principals cant be set to administrators of gateways, so you cant use them&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. Users must be set as administrators of gateways&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;4. The user must be assigned as a user of the data source defined on the gateway (different from being a gateway admin)&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/Developer/Getting-Token-for-API-Dataflow-Gateway-Binding/m-p/2351871" target="_self"&gt;&lt;SPAN&gt;Getting Token for API Dataflow Gateway Binding&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jun 2022 08:07:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Gateway-Binding-using-the-API/m-p/2611373#M37102</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-06-30T08:07:43Z</dc:date>
    </item>
    <item>
      <title>Re: Gateway Binding using the API</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Gateway-Binding-using-the-API/m-p/2614767#M37133</link>
      <description>&lt;P&gt;I tried the suggestions in that post, but no luck.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jul 2022 18:07:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Gateway-Binding-using-the-API/m-p/2614767#M37133</guid>
      <dc:creator>bmtolleson</dc:creator>
      <dc:date>2022-07-01T18:07:54Z</dc:date>
    </item>
  </channel>
</rss>

