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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
ducky
Advocate I
Advocate I

Change Paginated Report Dataset programatically

I have a few paginated reports (embedded ) that are connected to a dataset that is in another workspace (different from where the paginated reports are)

I want to change the datasource they are connected to another that is in another workspace. 

 

im using this method:

$endpoint = "https://api.powerbi.com/v1.0/myorg/groups/$workspaceId/reports/$reportId/Default.UpdateDatasources"
        $body = @{
          updateDetails = @(
              @{
                datasourceName = "OLD_datasource_name"
                connectionDetails = @{
                    server = "pbiazure://api.powerbi.com/"
                    database = "sobe_wowvirtualserver-hashvalue"
                  }
              },
              @{
                datasourceName = "NEW_datasource_name"
                connectionDetails = @{
                    server = "pbiazure://api.powerbi.com/"
                    database = "sobe_wowvirtualserver-hashvalue"
                  }
              }
          )
        } | ConvertTo-Json -Depth 10
Invoke-PowerBIRestMethod -Url $endpoint -Method POST -Body $body
 
The error I get is:
Encountered errors when invoking the command: { "code": "ItemNotFound", "message": "Datasource NEW_datasource_name was not found within the report datasources" }
 
anyone was able to make this work? 
1 ACCEPTED SOLUTION

@bradsy @v-hashadapu 

Sorry on my latency.

Keeping the same datasourceName didnt help. I get now the following error:
| One or more errors occurred. ({ "code": "InvalidRequest", "message": "Rdl UpdateDatasources updateDetails should not contain duplicated datasource Id's" })
 Invoke-PowerBIRestMethod -Url $endpoint -Method POST -Body $body
| Encountered errors when invoking the command: { "code": "InvalidRequest", "message": "Rdl UpdateDatasources updateDetails should not contain duplicated datasource
| Id's" }

 

Mind you that if I put the same datasourceName how does it knows how to switch ? 

 

To mention that the paginated report sits in a workspace(call it workspace1)  and is connected to a dataset from another workspace (call it workspace2). What I want is to reconnect the paginated report to a dataset from another workspace( call it workspace3). 

The service Principal is the admin of the workspaces. 

 

 

View solution in original post

7 REPLIES 7
v-hashadapu
Community Support
Community Support

Hi @ducky , Hope your issue is solved. If it is, please consider marking the answer 'Accept as solution', so others with similar issues may find it easily. If it isn't, please share the details.
Thank you.

v-hashadapu
Community Support
Community Support

Hi @ducky , Hope your issue is solved. If it is, please consider marking the answer 'Accept as solution', so others with similar issues may find it easily. If it isn't, please share the details.
Thank you.

v-hashadapu
Community Support
Community Support

Hi @ducky , Hope your issue is solved. If it is, please consider marking the answer 'Accept as solution', so others with similar issues may find it easily. If it isn't, please share the details. Thank you.

v-hashadapu
Community Support
Community Support

Hi @ducky , thank you for reaching out to the Microsoft Fabric Community Forum.


As mentioned by @bradsy, One should Keep the datasourceName the same as it exists in the paginated report and update the connectionDetails to point to the new data source.

Try it and If this helps, please consider marking it 'Accept as Solution' so others with similar queries may find it more easily. If not, please share the details.
Thank you.

bradsy
Microsoft Employee
Microsoft Employee

That is not look like how the API works. The datasourceName does not change. You would use the same data source name, but update the connectionDetails.

@bradsy @v-hashadapu 

Sorry on my latency.

Keeping the same datasourceName didnt help. I get now the following error:
| One or more errors occurred. ({ "code": "InvalidRequest", "message": "Rdl UpdateDatasources updateDetails should not contain duplicated datasource Id's" })
 Invoke-PowerBIRestMethod -Url $endpoint -Method POST -Body $body
| Encountered errors when invoking the command: { "code": "InvalidRequest", "message": "Rdl UpdateDatasources updateDetails should not contain duplicated datasource
| Id's" }

 

Mind you that if I put the same datasourceName how does it knows how to switch ? 

 

To mention that the paginated report sits in a workspace(call it workspace1)  and is connected to a dataset from another workspace (call it workspace2). What I want is to reconnect the paginated report to a dataset from another workspace( call it workspace3). 

The service Principal is the admin of the workspaces. 

 

 

I think I figured it out: In the body i dont need 2 datasources. I would keep only the current one (with its datasourcename ) but change the connection details. so the documentation was wrong to show the body like that. 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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