<?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: Set data source credentials on Power BI Report Server through REST API to create a scheduled refresh in Report Server</title>
    <link>https://community.fabric.microsoft.com/t5/Report-Server/Set-data-source-credentials-on-Power-BI-Report-Server-through/m-p/2641102#M24880</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="109790" data-lia-user-login="d_gosbell" class="lia-mention lia-mention-user"&gt;d_gosbell&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to change the credentials of a datasource with the power bi server api but I get the error "(400) Bad Request".&lt;/P&gt;&lt;P&gt;The difference is that when I make the call to get the details from the datasource, this is the only thing that is returned( there are many properties that you indicate in your call and&amp;nbsp; I dont have the information):&lt;BR /&gt;&lt;EM&gt;{&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Id=XXXXXXXXXXXXXXXXXX&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Name=;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Description=;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Path=;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Type=DataSource;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Hidden=False;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Size=0;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;ModifiedBy="XXXXXX";&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;ModifiedDate=2022-07-13T12:17:24.08+02:00;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;CreatedBy="XXXXXX";&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;CreatedDate=2022-07-13T12:16:38.52+02:00;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;ParentFolderId=;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;IsFavorite=False;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;ContentType=;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Content=;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;IsEnabled=True;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;ConnectionString=dwh_pro;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;DataSourceType=;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;IsOriginalConnectionStringExpressionBased=False;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;IsConnectionStringOverridden=False;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;CredentialRetrieval=prompt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;IsReference=False;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;DataSourceSubType=DataModel;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Roles=System.Object[];&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;CredentialsByUser=;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;CredentialsInServer=;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;DataModelDataSource=&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;}&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;About datasource: it is a connection to Oracle with Basic Autehntication (no windows like the example): Username and Password.&lt;/P&gt;&lt;P&gt;I detail the script to see if you can help me:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;$payload =&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;@"&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;{&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"Id": "XXXXXXXXXXXXXXXXXX",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"Name": "",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"Description": "",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"Path": "",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"Type": "DataSource",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"Hidden": False,&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"Size": 0,&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"ModifiedBy": "XXXXXXXX",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"ModifiedDate": "2022-07-13T12:17:24.08+02:00",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"CreatedBy": "XXXXXXXX,&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"CreatedDate": "2022-07-13T12:16:38.52+02:00",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"ParentFolderId": "XXXXXXXXXX",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"ContentType": "",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"Content": "",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"IsFavorite": False,&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"IsEnabled": true,&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"ConnectionString": "dwh_pro",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"DataModelDataSource": {&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"AuthType": "Unknown",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"SupportedAuthTypes": [&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;""&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;],&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"Kind": "Oracle",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"ModelConnectionName": "",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"Secret": "XXXXX",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"Type": "Import",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"Username": "XXXXXX"&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;},&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"DataSourceSubType": "DataModel",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"DataSourceType": "Oracle",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"IsOriginalConnectionStringExpressionBased": False,&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"IsConnectionStringOverridden": true,&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"CredentialRetrieval": "store",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"CredentialsByUser": {&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"DisplayText": "",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"UseAsWindowsCredentials": false&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;},&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"CredentialsInServer": {&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"UserName": "XXXXX",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"Password": "XXXXX",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"UseAsWindowsCredentials": false,&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"ImpersonateAuthenticatedUser": false&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;},&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"IsReference": false&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;}&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;}&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"@&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;$restApiUri = "&lt;A href="https://XXXXX" target="_blank"&gt;https://XXXXX&lt;/A&gt;" + "/api/v2.0/PowerBIReports(id)/DataSources"&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;$user = "XXXXX"&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;$pass= "XXXXXX"&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;$proxy = "&lt;A href="http://XXXXXX" target="_blank"&gt;http://XXXXXX&lt;/A&gt;"&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;$proxycred = "XXXXX"&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;$secpasswd = ConvertTo-SecureString $pass -AsPlainText -Force&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;$credential = New-Object System.Management.Automation.PSCredential($user, $secpasswd)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;$inicio = (get-date).ToString('f')&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Invoke-RestMethod -Uri $restApiUri -Method 'Patch' -Body $payload -ContentType "application/json" -Credential $credential -Proxy $proxy -ProxyCredential $proxycred -UseBasicParsing -Verbose&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks you very much&lt;/P&gt;</description>
    <pubDate>Fri, 15 Jul 2022 10:18:18 GMT</pubDate>
    <dc:creator>ClaraPS33</dc:creator>
    <dc:date>2022-07-15T10:18:18Z</dc:date>
    <item>
      <title>Set data source credentials on Power BI Report Server through REST API to create a scheduled refresh</title>
      <link>https://community.fabric.microsoft.com/t5/Report-Server/Set-data-source-credentials-on-Power-BI-Report-Server-through/m-p/928279#M12987</link>
      <description>&lt;P&gt;My task is the following: using the Power BI Report Server (PBIRS)&lt;SPAN&gt;&amp;nbsp;REST API,&lt;/SPAN&gt;&amp;nbsp;upload an embedded report (embedded meaning that the data model is integrated in the report itself - a simple import from an SQL Server database, hence no live connection or DirectQuery etc.) to PBIRS, set the credentials (ConnectionString, Windows Authentication username and password) to access the data source (the database) and set up a daily scheduled refresh.&lt;/P&gt;&lt;P&gt;With a Powershell script I'm able to upload the report with no problem, however complications arise when I try to set the credentials to the data source. Here is the code I currently have to accomplish this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;$payload0 =&lt;BR /&gt;'&lt;BR /&gt;{&lt;BR /&gt;"Name": "Data Source test",&lt;BR /&gt;"Description": "string",&lt;BR /&gt;"Path": "/Valid/Path",&lt;BR /&gt;"Type": "DataSource",&lt;BR /&gt;"Hidden": false,&lt;BR /&gt;"Size": 0,&lt;BR /&gt;"ModifiedBy": "string",&lt;BR /&gt;"ModifiedDate": "2020-01-13T15:51:04Z",&lt;BR /&gt;"CreatedBy": "string",&lt;BR /&gt;"CreatedDate": "2020-01-13T15:51:04Z",&lt;BR /&gt;"IsFavorite": false,&lt;BR /&gt;"IsEnabled": true,&lt;BR /&gt;"ConnectionString": "valid.connection\\string",&lt;BR /&gt;"DataModelDataSource": {&lt;BR /&gt;"AuthType": "Windows",&lt;BR /&gt;"SupportedAuthTypes": [&lt;BR /&gt;"Windows"&lt;BR /&gt;],&lt;BR /&gt;"Kind": "SQL",&lt;BR /&gt;"ModelConnectionName": "string",&lt;BR /&gt;"Secret": "",&lt;BR /&gt;"Type": "Import ",&lt;BR /&gt;"Username": "myUserName"&lt;BR /&gt;},&lt;BR /&gt;"DataSourceSubType": "DataModel",&lt;BR /&gt;"DataSourceType": "SQL",&lt;BR /&gt;"IsOriginalConnectionStringExpressionBased": false,&lt;BR /&gt;"IsConnectionStringOverridden": false,&lt;BR /&gt;"CredentialRetrieval": "prompt",&lt;BR /&gt;"CredentialsByUser": {&lt;BR /&gt;"DisplayText": "someText",&lt;BR /&gt;"UseAsWindowsCredentials": true&lt;BR /&gt;},&lt;BR /&gt;"CredentialsInServer": {&lt;BR /&gt;"UserName": "myUserName",&lt;BR /&gt;"Password": "myPassword",&lt;BR /&gt;"UseAsWindowsCredentials": true,&lt;BR /&gt;"ImpersonateAuthenticatedUser": true&lt;BR /&gt;},&lt;BR /&gt;"IsReference": false&lt;BR /&gt;}&lt;BR /&gt;'&lt;/P&gt;&lt;P&gt;$restApiUri = $ReportPortalUri + "/api/v2.0/DataSources"&lt;/P&gt;&lt;P&gt;Invoke-RestMethod -Uri $restApiUri -Method Post -Body $payload0 -ContentType "application/json" -UseDefaultCredentials -UseBasicParsing -Verbose&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After running the code I get a&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;201 Created&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;response JSON that indicates the successful creation of the data source and its access credentials. If I check on the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;Manage&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;pane of the report on PBIRS&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;I don't see any changes made to the data sources.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;My next step was to set the credentials manually by entering my username and password on the report server and then executing the following code to set up a scheduled refresh:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;$payload1 =&lt;BR /&gt;'&lt;BR /&gt;{&lt;BR /&gt;"ParameterValues":[&lt;/P&gt;&lt;P&gt;],&lt;BR /&gt;"Description":"testSchedule",&lt;BR /&gt;"CatalogItemPath":"/Valid/Path",&lt;BR /&gt;"EventType":"DataModelRefresh",&lt;BR /&gt;"Schedule":{&lt;BR /&gt;"Definition":{&lt;BR /&gt;"EndDate":"0001-01-01T00:00:00Z",&lt;BR /&gt;"StartDateTime":"2019-01-15T02:00:00Z",&lt;BR /&gt;"EndDateSpecified":false,&lt;BR /&gt;"Recurrence":{&lt;BR /&gt;"DailyRecurrence": {&lt;BR /&gt;"DaysInterval":1&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;'&lt;/P&gt;&lt;P&gt;$restApiUri = $ReportPortalUri + "/api/v2.0/CacheRefreshPlans"&lt;/P&gt;&lt;P&gt;Invoke-RestMethod -Uri $restApiUri -Method Post -Body $payload1 -ContentType "application/json" -UseDefaultCredentials -UseBasicParsing -Verbose&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Running this code results in the successful creation of the scheduled refresh given that I set up the credentials to the data source manually beforehand.&lt;/P&gt;&lt;P&gt;So my question in short: how to set up the credentials (Windows Authentication and username/password) of a data source (the SQL Server connection defined by a valid ConnectionString) with the PBIRS REST API?&lt;/P&gt;&lt;P&gt;Any help would be appreciated!&lt;/P&gt;</description>
      <pubDate>Tue, 11 Feb 2020 10:46:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Report-Server/Set-data-source-credentials-on-Power-BI-Report-Server-through/m-p/928279#M12987</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-02-11T10:46:23Z</dc:date>
    </item>
    <item>
      <title>Re: Set data source credentials on Power BI Report Server through REST API to create a scheduled refresh</title>
      <link>https://community.fabric.microsoft.com/t5/Report-Server/Set-data-source-credentials-on-Power-BI-Report-Server-through/m-p/929183#M13001</link>
      <description>&lt;P&gt;I've just done some tests and the following payload worked for me doing a PATCH http request against&amp;nbsp;&lt;SPAN&gt;http://localhost/Reports/api/v2.0/PowerBIReports( {id} )/DataSources&lt;/SPAN&gt;. Note I've changed the &lt;STRONG&gt;CredentialRetrieval&lt;/STRONG&gt; value to &lt;STRONG&gt;"store"&lt;/STRONG&gt; and I found I had to add the username and password both in the CredentialsInServer object and as the username/secret in the DataModelDataSource (if I did not so this second bit the scheduled refresh would not work). I've also stripped out the creation and modification fields as I don't think you can alter those from the client side anyway.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;[
    {
        "Id": "dcf1ca8d-4320-e911-bbac-94b86df86523",
        "Name": null,
        "Description": null,
        "Hidden": false,
        "Path": "",
        "IsEnabled": true,
        "DataSourceSubType": "DataModel",
        "DataModelDataSource": {
            "Type": "Import",
            "Kind": "SQL",
            "AuthType": "Windows",
            "SupportedAuthTypes": [
                "Windows",
                "UsernamePassword"
            ],
            "Username": "domain\\user",
            "Secret": "MyPassword",
            "ModelConnectionName": ""
        },
        "IsReference": false,
        "DataSourceType": "SQL",
        "ConnectionString": "localhost\\sql17;AdventureWorksDW2017",
        "IsConnectionStringOverridden": true,
        "CredentialRetrieval": "store",
        "CredentialsInServer": {
            "UserName": "domain\\user",
            "Password": "MyPassword",
            "UseAsWindowsCredentials": true,
            "ImpersonateAuthenticatedUser": false
        },
        "CredentialsByUser": null
        
    }
]&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Feb 2020 22:36:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Report-Server/Set-data-source-credentials-on-Power-BI-Report-Server-through/m-p/929183#M13001</guid>
      <dc:creator>d_gosbell</dc:creator>
      <dc:date>2020-02-11T22:36:56Z</dc:date>
    </item>
    <item>
      <title>Re: Set data source credentials on Power BI Report Server through REST API to create a scheduled refresh</title>
      <link>https://community.fabric.microsoft.com/t5/Report-Server/Set-data-source-credentials-on-Power-BI-Report-Server-through/m-p/929559#M13006</link>
      <description>&lt;P&gt;Thank you very much, worked perfectly!&lt;/P&gt;</description>
      <pubDate>Wed, 12 Feb 2020 07:05:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Report-Server/Set-data-source-credentials-on-Power-BI-Report-Server-through/m-p/929559#M13006</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-02-12T07:05:24Z</dc:date>
    </item>
    <item>
      <title>Re: Set data source credentials on Power BI Report Server through REST API to create a scheduled refresh</title>
      <link>https://community.fabric.microsoft.com/t5/Report-Server/Set-data-source-credentials-on-Power-BI-Report-Server-through/m-p/2641102#M24880</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="109790" data-lia-user-login="d_gosbell" class="lia-mention lia-mention-user"&gt;d_gosbell&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to change the credentials of a datasource with the power bi server api but I get the error "(400) Bad Request".&lt;/P&gt;&lt;P&gt;The difference is that when I make the call to get the details from the datasource, this is the only thing that is returned( there are many properties that you indicate in your call and&amp;nbsp; I dont have the information):&lt;BR /&gt;&lt;EM&gt;{&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Id=XXXXXXXXXXXXXXXXXX&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Name=;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Description=;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Path=;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Type=DataSource;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Hidden=False;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Size=0;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;ModifiedBy="XXXXXX";&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;ModifiedDate=2022-07-13T12:17:24.08+02:00;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;CreatedBy="XXXXXX";&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;CreatedDate=2022-07-13T12:16:38.52+02:00;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;ParentFolderId=;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;IsFavorite=False;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;ContentType=;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Content=;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;IsEnabled=True;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;ConnectionString=dwh_pro;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;DataSourceType=;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;IsOriginalConnectionStringExpressionBased=False;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;IsConnectionStringOverridden=False;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;CredentialRetrieval=prompt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;IsReference=False;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;DataSourceSubType=DataModel;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Roles=System.Object[];&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;CredentialsByUser=;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;CredentialsInServer=;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;DataModelDataSource=&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;}&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;About datasource: it is a connection to Oracle with Basic Autehntication (no windows like the example): Username and Password.&lt;/P&gt;&lt;P&gt;I detail the script to see if you can help me:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;$payload =&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;@"&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;{&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"Id": "XXXXXXXXXXXXXXXXXX",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"Name": "",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"Description": "",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"Path": "",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"Type": "DataSource",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"Hidden": False,&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"Size": 0,&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"ModifiedBy": "XXXXXXXX",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"ModifiedDate": "2022-07-13T12:17:24.08+02:00",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"CreatedBy": "XXXXXXXX,&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"CreatedDate": "2022-07-13T12:16:38.52+02:00",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"ParentFolderId": "XXXXXXXXXX",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"ContentType": "",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"Content": "",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"IsFavorite": False,&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"IsEnabled": true,&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"ConnectionString": "dwh_pro",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"DataModelDataSource": {&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"AuthType": "Unknown",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"SupportedAuthTypes": [&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;""&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;],&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"Kind": "Oracle",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"ModelConnectionName": "",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"Secret": "XXXXX",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"Type": "Import",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"Username": "XXXXXX"&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;},&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"DataSourceSubType": "DataModel",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"DataSourceType": "Oracle",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"IsOriginalConnectionStringExpressionBased": False,&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"IsConnectionStringOverridden": true,&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"CredentialRetrieval": "store",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"CredentialsByUser": {&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"DisplayText": "",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"UseAsWindowsCredentials": false&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;},&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"CredentialsInServer": {&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"UserName": "XXXXX",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"Password": "XXXXX",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"UseAsWindowsCredentials": false,&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"ImpersonateAuthenticatedUser": false&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;},&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"IsReference": false&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;}&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;}&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"@&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;$restApiUri = "&lt;A href="https://XXXXX" target="_blank"&gt;https://XXXXX&lt;/A&gt;" + "/api/v2.0/PowerBIReports(id)/DataSources"&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;$user = "XXXXX"&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;$pass= "XXXXXX"&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;$proxy = "&lt;A href="http://XXXXXX" target="_blank"&gt;http://XXXXXX&lt;/A&gt;"&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;$proxycred = "XXXXX"&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;$secpasswd = ConvertTo-SecureString $pass -AsPlainText -Force&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;$credential = New-Object System.Management.Automation.PSCredential($user, $secpasswd)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;$inicio = (get-date).ToString('f')&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Invoke-RestMethod -Uri $restApiUri -Method 'Patch' -Body $payload -ContentType "application/json" -Credential $credential -Proxy $proxy -ProxyCredential $proxycred -UseBasicParsing -Verbose&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks you very much&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jul 2022 10:18:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Report-Server/Set-data-source-credentials-on-Power-BI-Report-Server-through/m-p/2641102#M24880</guid>
      <dc:creator>ClaraPS33</dc:creator>
      <dc:date>2022-07-15T10:18:18Z</dc:date>
    </item>
    <item>
      <title>Re: Set data source credentials on Power BI Report Server through REST API to create a scheduled refresh</title>
      <link>https://community.fabric.microsoft.com/t5/Report-Server/Set-data-source-credentials-on-Power-BI-Report-Server-through/m-p/3527853#M31774</link>
      <description>&lt;P&gt;I wrote belo script in Powershell to achieve this:&lt;BR /&gt;&lt;BR /&gt;$urlapiEndpoint = "/datasets/$($datasetObject.Id)/datasources"&lt;/P&gt;&lt;P&gt;$apiResponse = Invoke-PowerBIRestMethod -Url $urlapiEndpoint -Method Get&lt;/P&gt;&lt;P&gt;Write-Host "API Response:`n$apiResponse"&lt;/P&gt;&lt;P&gt;$parsedJSON = $apiResponse | ConvertFrom-Json&lt;/P&gt;&lt;P&gt;Write-Host "Parsed Response:`n$parsedJSON"&lt;/P&gt;&lt;P&gt;# Extract values from the API response&lt;BR /&gt;$datasourceId = $parsedJson.value[0].datasourceId&lt;BR /&gt;$gatewayId = $parsedJson.value[0].gatewayId&lt;/P&gt;&lt;P&gt;# Output the extracted values&lt;BR /&gt;Write-Host "DatasourceId: $datasourceId"&lt;BR /&gt;Write-Host "GatewayId: $gatewayId"&lt;/P&gt;&lt;P&gt;#region Initialize&lt;/P&gt;&lt;P&gt;# EncryptGatewayCredentials script path&lt;/P&gt;&lt;P&gt;# Update datasource API details&lt;BR /&gt;$GatewayId = $gatewayId #"918adac3-337a-4023-8550-706671a65fd9"&lt;BR /&gt;$DatasourceId = $datasourceId #"e36df50d-ba00-4087-a34f-b5a86482c0d1"&lt;BR /&gt;$UpdateDatasourceUrl = "/gateways/$GatewayId/datasources/$DatasourceId"&lt;BR /&gt;$GetGatewayUrl = "/gateways/$GatewayId"&lt;/P&gt;&lt;P&gt;## Datasource details&lt;BR /&gt;##SQL/Windows&lt;BR /&gt;# username = SQL user in case of basic credentials, or windows user in case of windows credentials&lt;BR /&gt;$username = $dbuser&lt;BR /&gt;# password = SQL user password in case of basic credentials, or windows user password in case of windows credentials&lt;BR /&gt;$password = $dbpass&lt;BR /&gt;#endregion&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Get gateway public key&lt;BR /&gt;$GatewayObject = Invoke-PowerBIRestMethod -Url $GetGatewayUrl -Method Get | ConvertFrom-Json&lt;/P&gt;&lt;P&gt;$GatewayObject&lt;/P&gt;&lt;P&gt;$GatewayPublicKey = $GatewayObject.publicKey&lt;BR /&gt;$gatewayExponent = $GatewayPublicKey.exponent&lt;BR /&gt;$gatewayModulus = $GatewayPublicKey.modulus&lt;/P&gt;&lt;P&gt;# Encrypt basic credentials using EncryptGatewayCredentials script&lt;BR /&gt;Import-Module $EncryptCredentialsScriptPath&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;function EncryptBasicCredentials {&lt;BR /&gt;param (&lt;BR /&gt;[Parameter(Mandatory=$True,Position=1)]&lt;BR /&gt;[String]$Username,&lt;BR /&gt;[Parameter(Mandatory=$True,Position=2)]&lt;BR /&gt;[String]$PasswordAsString,&lt;BR /&gt;[Parameter(Mandatory=$True,Position=3)]&lt;BR /&gt;[string]$GatewayExponent,&lt;BR /&gt;[Parameter(Mandatory=$True,Position=4)]&lt;BR /&gt;[string]$GatewayModulus&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;write-host "In the funcion "&lt;BR /&gt;&lt;BR /&gt;# Create the objects to perform the necessary encryption on the credentials. Again, since I'm using basic credentials, I'm constructing a new BasicCredentials class. Other classes can be found here: &lt;A href="https://github.com/microsoft/PowerBI-CSharp/tree/bf7cdf047a0218f7a8555fa7966445812a043955/sdk/PowerBI.Api/Extensions/Models/Credentials" target="_blank"&gt;https://github.com/microsoft/PowerBI-CSharp/tree/bf7cdf047a0218f7a8555fa7966445812a043955/sdk/PowerBI.Api/Extensions/Models/Credentials&lt;/A&gt;&lt;BR /&gt;$gatewayKeyObj = [Microsoft.PowerBI.Api.Models.GatewayPublicKey]::new($GatewayExponent, $GatewayModulus)&lt;BR /&gt;$credentialsEncryptor = [Microsoft.PowerBI.Api.Extensions.AsymmetricKeyEncryptor]::new($gatewayKeyObj)&lt;BR /&gt;$basicCreds = [Microsoft.PowerBI.Api.Models.Credentials.BasicCredentials]::new($username, $PasswordAsString)&lt;/P&gt;&lt;P&gt;# Construct the CredentialDetails object. The resulting "Credentials" property on this object will have been encrypted appropriately, ready for use in the request payload.&lt;BR /&gt;$credentialDetails = [Microsoft.PowerBI.Api.Models.CredentialDetails]::new(&lt;BR /&gt;$basicCreds,&lt;BR /&gt;[Microsoft.PowerBI.Api.Models.PrivacyLevel]::Organizational,&lt;BR /&gt;[Microsoft.PowerBI.Api.Models.EncryptedConnection]::Encrypted,&lt;BR /&gt;$credentialsEncryptor)&lt;BR /&gt;&lt;BR /&gt;# Construct the body for the API request.&lt;BR /&gt;$body = @{&lt;BR /&gt;credentialDetails = @{&lt;BR /&gt;credentialType = "Basic";&lt;BR /&gt;credentials = $credentialDetails.Credentials;&lt;BR /&gt;encryptedConnection = "Encrypted";&lt;BR /&gt;encryptionAlgorithm = "RSA-OAEP";&lt;BR /&gt;privacyLevel = "Organizational";&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;$bodyJson = $body | ConvertTo-Json&lt;/P&gt;&lt;P&gt;Write-Output $bodyJson&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;$encryptedCredentials = EncryptBasicCredentials -Username $username -PasswordAsString $password -GatewayExponent $gatewayExponent -GatewayModulus $gatewayModulus&lt;/P&gt;&lt;P&gt;$encryptedCredentials&lt;BR /&gt;$UpdateDatasourceUrl&lt;/P&gt;&lt;P&gt;Invoke-PowerBIRestMethod -Url $UpdateDatasourceUrl -Method Patch -Body $encryptedCredentials&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2023 14:02:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Report-Server/Set-data-source-credentials-on-Power-BI-Report-Server-through/m-p/3527853#M31774</guid>
      <dc:creator>MRIZ</dc:creator>
      <dc:date>2023-11-10T14:02:37Z</dc:date>
    </item>
  </channel>
</rss>

