Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Set data source credentials on Power BI Report Server through REST API to create a scheduled refresh

My task is the following: using the Power BI Report Server (PBIRS) REST API, upload an embedded report (embedded meaning that the data model is integrated in the report itself - a simple import from ...
  • d_gosbell's avatar
    6 years ago

    I've just done some tests and the following payload worked for me doing a PATCH http request against http://localhost/Reports/api/v2.0/PowerBIReports( {id} )/DataSources. Note I've changed the CredentialRetrieval value to "store" 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.

     

    [
        {
            "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
            
        }
    ]