<?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 Update Source Credentials with PowerShell for Web Type &amp;amp; Anonymous in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Update-Source-Credentials-with-PowerShell-for-Web-Type-amp/m-p/2095020#M32005</link>
    <description>&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;Hi,&lt;/P&gt;&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;I'm new to PowerBI but not to PowerShell.&lt;/P&gt;&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;I've got a dataset which is a Web type and is coming from Azure API. The credentials are anonymous, the parameters handle the authentication eg apikey and so on.&lt;/P&gt;&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;I want to refresh it automatically each day using the service principal. I can do the take over of the dataset and initiate a refresh as the SP, but it then fails due to an error validating the source credentials. If i could actually skip this section it would just work.&lt;/P&gt;&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;So i am now trying to perform creating a new Web type Anonymous credential with PowerShell as the SP but I'm hitting some bugs.&lt;/P&gt;&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;Here is my credential setting in the powerbi gui:&lt;/P&gt;&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sweggle_0-1632413586717.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/599727i09474D1D195CD641/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sweggle_0-1632413586717.png" alt="sweggle_0-1632413586717.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;However, after my SP takes over the dataset and tries to refresh it, i get this dreaded error. SO i assume I need to update / delete and recreate the credentials.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sweggle_1-1632413664848.png" style="width: 675px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/599729iC8AF4373544F00BE/image-dimensions/675x41?v=v2" width="675" height="41" role="button" title="sweggle_1-1632413664848.png" alt="sweggle_1-1632413664848.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;I followed something from the MS PowerBI Github that is very similar but for a SQL source: &lt;A href="https://github.com/microsoft/PowerBI-Developer-Samples/blob/master/PowerShell%20Scripts/Update-Connection-Details-for-Sql-Datasource.ps1" target="_blank" rel="noopener nofollow ugc"&gt;PowerShell&lt;/A&gt;&lt;/P&gt;&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;I've edited the code slightly to look like this, but i still get a generic 500 error.&lt;/P&gt;&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;# create HTTP request body to update datasource connection details
$postBody = @{
  "updateDetails" = @(
   @{
    "connectionDetails" = @{
      "url" = "https://xxx.azure-api.net/"
    }
    "datasourceSelector" = @{
      "datasourceType" = "Web"
      "connectionDetails" = @{
        "url" = "https://xxx.azure-api.net/"
      }
      "gatewayId" = "$gatewayId"
      "datasourceId" = "$datasourceId"
    }
  })
}

# convert body contents to JSON
$postBodyJson = ConvertTo-Json -InputObject $postBody -Depth 6 -Compress

# execute POST operation to update datasource connection details
Invoke-PowerBIRestMethod -Method Post -Url $datasourePatchUrl -Body $postBodyJson&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've also tried it like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;$New = @{
    dataSourceType = "Web"
    datasourceName = "Dummy Web Connection"
    connectionDetails = "{`"url`":`"https://xxx.azure-api.net/`"}"
    credentialDetails = @{
        credentialType = "Anonymous"
        credentials = "{`"credentialData`":`"`"}"
        encryptedConnection = "NotEncrypted"
        encryptionAlgorithm = "None"
        privacyLevel = "None"
    }
} | ConvertTo-Json


Invoke-PowerBIRestMethod -Url "gateways/$GatewayId/datasources/" -Method Post -Body $new -Verbose&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;However in fiddler i get the following:&lt;/P&gt;&lt;PRE&gt;A7
{"error":{"code":"DMTS_InvalidEncryptionAlgorithmError","pbi.error":{"code":"DMTS_InvalidEncryptionAlgorithmError","parameters":{},"details":[],"exceptionCulprit":1}}}
0&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My source type is web and credential type is anonymous. There is no username or password, this should be really straightforward but I am finding it very difficult to overcome this issue - hoping someone can help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help appreciated!&lt;/P&gt;</description>
    <pubDate>Thu, 23 Sep 2021 16:15:37 GMT</pubDate>
    <dc:creator>sweggle</dc:creator>
    <dc:date>2021-09-23T16:15:37Z</dc:date>
    <item>
      <title>Update Source Credentials with PowerShell for Web Type &amp; Anonymous</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Update-Source-Credentials-with-PowerShell-for-Web-Type-amp/m-p/2095020#M32005</link>
      <description>&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;Hi,&lt;/P&gt;&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;I'm new to PowerBI but not to PowerShell.&lt;/P&gt;&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;I've got a dataset which is a Web type and is coming from Azure API. The credentials are anonymous, the parameters handle the authentication eg apikey and so on.&lt;/P&gt;&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;I want to refresh it automatically each day using the service principal. I can do the take over of the dataset and initiate a refresh as the SP, but it then fails due to an error validating the source credentials. If i could actually skip this section it would just work.&lt;/P&gt;&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;So i am now trying to perform creating a new Web type Anonymous credential with PowerShell as the SP but I'm hitting some bugs.&lt;/P&gt;&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;Here is my credential setting in the powerbi gui:&lt;/P&gt;&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sweggle_0-1632413586717.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/599727i09474D1D195CD641/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sweggle_0-1632413586717.png" alt="sweggle_0-1632413586717.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;However, after my SP takes over the dataset and tries to refresh it, i get this dreaded error. SO i assume I need to update / delete and recreate the credentials.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sweggle_1-1632413664848.png" style="width: 675px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/599729iC8AF4373544F00BE/image-dimensions/675x41?v=v2" width="675" height="41" role="button" title="sweggle_1-1632413664848.png" alt="sweggle_1-1632413664848.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;I followed something from the MS PowerBI Github that is very similar but for a SQL source: &lt;A href="https://github.com/microsoft/PowerBI-Developer-Samples/blob/master/PowerShell%20Scripts/Update-Connection-Details-for-Sql-Datasource.ps1" target="_blank" rel="noopener nofollow ugc"&gt;PowerShell&lt;/A&gt;&lt;/P&gt;&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;I've edited the code slightly to look like this, but i still get a generic 500 error.&lt;/P&gt;&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;# create HTTP request body to update datasource connection details
$postBody = @{
  "updateDetails" = @(
   @{
    "connectionDetails" = @{
      "url" = "https://xxx.azure-api.net/"
    }
    "datasourceSelector" = @{
      "datasourceType" = "Web"
      "connectionDetails" = @{
        "url" = "https://xxx.azure-api.net/"
      }
      "gatewayId" = "$gatewayId"
      "datasourceId" = "$datasourceId"
    }
  })
}

# convert body contents to JSON
$postBodyJson = ConvertTo-Json -InputObject $postBody -Depth 6 -Compress

# execute POST operation to update datasource connection details
Invoke-PowerBIRestMethod -Method Post -Url $datasourePatchUrl -Body $postBodyJson&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've also tried it like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;$New = @{
    dataSourceType = "Web"
    datasourceName = "Dummy Web Connection"
    connectionDetails = "{`"url`":`"https://xxx.azure-api.net/`"}"
    credentialDetails = @{
        credentialType = "Anonymous"
        credentials = "{`"credentialData`":`"`"}"
        encryptedConnection = "NotEncrypted"
        encryptionAlgorithm = "None"
        privacyLevel = "None"
    }
} | ConvertTo-Json


Invoke-PowerBIRestMethod -Url "gateways/$GatewayId/datasources/" -Method Post -Body $new -Verbose&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;However in fiddler i get the following:&lt;/P&gt;&lt;PRE&gt;A7
{"error":{"code":"DMTS_InvalidEncryptionAlgorithmError","pbi.error":{"code":"DMTS_InvalidEncryptionAlgorithmError","parameters":{},"details":[],"exceptionCulprit":1}}}
0&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My source type is web and credential type is anonymous. There is no username or password, this should be really straightforward but I am finding it very difficult to overcome this issue - hoping someone can help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help appreciated!&lt;/P&gt;</description>
      <pubDate>Thu, 23 Sep 2021 16:15:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Update-Source-Credentials-with-PowerShell-for-Web-Type-amp/m-p/2095020#M32005</guid>
      <dc:creator>sweggle</dc:creator>
      <dc:date>2021-09-23T16:15:37Z</dc:date>
    </item>
    <item>
      <title>Re: Update Source Credentials with PowerShell for Web Type &amp; Anonymous</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Update-Source-Credentials-with-PowerShell-for-Web-Type-amp/m-p/2099449#M32064</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/328245"&gt;@sweggle&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Please review the content in the following threads, hope they can help you.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blog.kloud.com.au/2018/07/23/use-anonymous-authentication-on-web-data-sources-with-a-api-key-in-url/" target="_self"&gt;&lt;STRONG&gt;Power BI: Using anonymous authentication on Web data sources with a API key in URL&lt;/STRONG&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://endjin.com/blog/2020/12/how-to-update-credentials-for-an-on-prem-power-bi-data-source-using-powershell" target="_self"&gt;&lt;STRONG&gt;How to update credentials for an on-prem Power BI data source using PowerShell&lt;/STRONG&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blog.crossjoin.co.uk/2019/04/25/skip-test-connection-power-bi-refresh-failures/" target="_self"&gt;&lt;STRONG&gt;Using The “Skip Test Connection” Option For Power BI Data Sources To Avoid Scheduled Refresh Failures&lt;/STRONG&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Mon, 27 Sep 2021 06:35:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Update-Source-Credentials-with-PowerShell-for-Web-Type-amp/m-p/2099449#M32064</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-09-27T06:35:26Z</dc:date>
    </item>
    <item>
      <title>Re: Update Source Credentials with PowerShell for Web Type &amp; Anonymous</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Update-Source-Credentials-with-PowerShell-for-Web-Type-amp/m-p/4132620#M55097</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;So is there a solution check the "skip test connection" checkbox for a service principal??&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2024 06:09:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Update-Source-Credentials-with-PowerShell-for-Web-Type-amp/m-p/4132620#M55097</guid>
      <dc:creator>thomasio</dc:creator>
      <dc:date>2024-09-04T06:09:17Z</dc:date>
    </item>
  </channel>
</rss>

