Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
whereismydata
Resolver IV
Resolver IV

PBIRS API issue

Hi,

 

following up on my previous question on how to batch update a password used in multiple reports. The recommendation was to use the api. 

 

I figured that I have to use this endpoint:

https://app.swaggerhub.com/apis/microsoft-rs/PBIRS/2.0#/PowerBIReports/UpdatePowerBIReportDataSource

 

But when I send this request:

[
  {
    "DataModelDataSource": {
      "Username": "dummy user"
    }
  }
]

the response is a 400 (bad request)

 

Authorization is no use since other request work fine.

 

Any idea what I am doing wrong?

 

Thank you 🙂

1 ACCEPTED SOLUTION

Hi,

 

based on your input I did some more research. The error was, as you expected, that the payload was wrong. I thougth because auf the patch method only several fields need to be put into the payload. But instead the whole body needs to be in the payload. Now it works fine.

 

body of the get request:

{
  "@odata.context": "uri",
  "value": [
    {
      "Id": "datasourceId",
      "Name": null,
      "Description": null,
      "Path": null,
      "Type": "DataSource",
      "Hidden": false,
      "Size": 0,
      "ModifiedBy": "name",
      "ModifiedDate": "datetime",
      "CreatedBy": "name",
      "CreatedDate": "datetime",
      "ParentFolderId": null,
      "IsFavorite": false,
      "Roles": [],
      "ContentType": null,
      "Content": "",
      "IsEnabled": true,
      "ConnectionString": "domain",
      "DataSourceType": null,
      "IsOriginalConnectionStringExpressionBased": false,
      "IsConnectionStringOverridden": false,
      "CredentialRetrieval": "prompt",
      "CredentialsByUser": null,
      "CredentialsInServer": null,
      "IsReference": false,
      "DataSourceSubType": "DataModel",
      "DataModelDataSource": {
        "Type": "Import",
        "Kind": "ActiveDirectory",
        "AuthType": "Windows",
        "SupportedAuthTypes": [
          "Windows",
          "UsernamePassword"
        ],
        "Username": "OldUsername",
        "Secret": "", //Password is empty in get request
        "ModelConnectionName": ""
      }
    }
  ]
}

 

 

this is the payload that worked for me (only use the value array):

[
  {
    "Id": "Datasource id",
    "Name": null,
    "Description": null,
    "Path": null,
    "Type": "DataSource",
    "Hidden": false,
    "Size": 0,
    "ModifiedBy": "name",
    "ModifiedDate": "datetime",
    "CreatedBy": "name",
    "CreatedDate": "datetime",
    "ParentFolderId": null,
    "IsFavorite": false,
    "Roles": [],
    "ContentType": null,
    "Content": "",
    "IsEnabled": true,
    "ConnectionString": "domain",
    "DataSourceType": null,
    "IsOriginalConnectionStringExpressionBased": false,
    "IsConnectionStringOverridden": false,
    "CredentialRetrieval": "prompt",
    "CredentialsByUser": null,
    "CredentialsInServer": null,
    "IsReference": false,
    "DataSourceSubType": "DataModel",
    "DataModelDataSource": {
      "Type": "Import",
      "Kind": "ActiveDirectory",
      "AuthType": "Windows",
      "SupportedAuthTypes": [
        "Windows",
        "UsernamePassword"
      ],
      "Username": "yourNewUsername",
      "Secret": "yourNewPassword",
      "ModelConnectionName": ""
    }
  }
]

 

regarding the id: I read that when there is more than one source, every source needs to be in the requestbody, even if nothing changes

 

useful links:

http://dataap.org/blog/2020/01/16/power-bi-report-server-change-data-source-using-rest-apis/

https://web.archive.org/web/20190215010547/https://parthpsha.com/programmatically-setting-and-verify... 

https://community.powerbi.com/t5/Report-Server/Power-Bi-report-deployment-to-Production/td-p/662197 

https://github.com/Microsoft/ReportingServicesTools/issues/116 

https://community.powerbi.com/t5/Report-Server/REST-API-on-PBIRS-on-prem-Oct-2017-Update-PowerBIRepo... 

 

View solution in original post

3 REPLIES 3
d_gosbell
Super User
Super User

So firstly make sure you are using the PATCH method for your request.

 

Then there are a couple of things wrong with your payload. Firstly you can have multiple datasources in a report so I'm pretty sure you would need to include the id of the datasource in your payload. And it does not make sense to just change the username, you would most likely need to also include the secret.

 

I would suggest that you first do a GET on this endpoint to get the array of existing datasources, then modify the username/secret and issue a PATCH request. 

Hi,

 

based on your input I did some more research. The error was, as you expected, that the payload was wrong. I thougth because auf the patch method only several fields need to be put into the payload. But instead the whole body needs to be in the payload. Now it works fine.

 

body of the get request:

{
  "@odata.context": "uri",
  "value": [
    {
      "Id": "datasourceId",
      "Name": null,
      "Description": null,
      "Path": null,
      "Type": "DataSource",
      "Hidden": false,
      "Size": 0,
      "ModifiedBy": "name",
      "ModifiedDate": "datetime",
      "CreatedBy": "name",
      "CreatedDate": "datetime",
      "ParentFolderId": null,
      "IsFavorite": false,
      "Roles": [],
      "ContentType": null,
      "Content": "",
      "IsEnabled": true,
      "ConnectionString": "domain",
      "DataSourceType": null,
      "IsOriginalConnectionStringExpressionBased": false,
      "IsConnectionStringOverridden": false,
      "CredentialRetrieval": "prompt",
      "CredentialsByUser": null,
      "CredentialsInServer": null,
      "IsReference": false,
      "DataSourceSubType": "DataModel",
      "DataModelDataSource": {
        "Type": "Import",
        "Kind": "ActiveDirectory",
        "AuthType": "Windows",
        "SupportedAuthTypes": [
          "Windows",
          "UsernamePassword"
        ],
        "Username": "OldUsername",
        "Secret": "", //Password is empty in get request
        "ModelConnectionName": ""
      }
    }
  ]
}

 

 

this is the payload that worked for me (only use the value array):

[
  {
    "Id": "Datasource id",
    "Name": null,
    "Description": null,
    "Path": null,
    "Type": "DataSource",
    "Hidden": false,
    "Size": 0,
    "ModifiedBy": "name",
    "ModifiedDate": "datetime",
    "CreatedBy": "name",
    "CreatedDate": "datetime",
    "ParentFolderId": null,
    "IsFavorite": false,
    "Roles": [],
    "ContentType": null,
    "Content": "",
    "IsEnabled": true,
    "ConnectionString": "domain",
    "DataSourceType": null,
    "IsOriginalConnectionStringExpressionBased": false,
    "IsConnectionStringOverridden": false,
    "CredentialRetrieval": "prompt",
    "CredentialsByUser": null,
    "CredentialsInServer": null,
    "IsReference": false,
    "DataSourceSubType": "DataModel",
    "DataModelDataSource": {
      "Type": "Import",
      "Kind": "ActiveDirectory",
      "AuthType": "Windows",
      "SupportedAuthTypes": [
        "Windows",
        "UsernamePassword"
      ],
      "Username": "yourNewUsername",
      "Secret": "yourNewPassword",
      "ModelConnectionName": ""
    }
  }
]

 

regarding the id: I read that when there is more than one source, every source needs to be in the requestbody, even if nothing changes

 

useful links:

http://dataap.org/blog/2020/01/16/power-bi-report-server-change-data-source-using-rest-apis/

https://web.archive.org/web/20190215010547/https://parthpsha.com/programmatically-setting-and-verify... 

https://community.powerbi.com/t5/Report-Server/Power-Bi-report-deployment-to-Production/td-p/662197 

https://github.com/Microsoft/ReportingServicesTools/issues/116 

https://community.powerbi.com/t5/Report-Server/REST-API-on-PBIRS-on-prem-Oct-2017-Update-PowerBIRepo... 

 


this is the payload that worked for me (only use the value array)

Thank you! I was trying to change a report's ConnectionString using the PATCH method and it was not working no matter what. Turns out I needed to use only the value array, and deleting the @odata.context thing before the value array made it work.

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.