Forum Discussion

Sam_Kumar's avatar
Sam_Kumar
Brass Contributor
Jan 14, 2025

Help In Editing Data Source Credentials in PowerShell for Power BI Embedded Dashboards in D365 CRM

Hello,

We are currently migrating Power BI embedded dashboards from one Dynamics 365 CRM tenant to another. The process involves creating a new Power BI report within a workspace. Since the Dynamics 365 Solution does not support the inclusion of Power BI reports within unmanaged solutions, we have resorted to using PowerShell scripting to manage the migration.

During this migration, we encountered an issue where the report IDs from the original environment remained linked when moving the Power BI embedded dashboards to the new environment. To address this, we have utilized Environment Variables to map the new report and workspace IDs appropriately.

However, we are facing an issue when attempting to edit the Data Source Credentials using PowerShell scripting. Specifically, we are receiving a "Bad Request" error, as shown in the screenshot below.

 

 

Here is the PowerShell code we are currently using to edit the Data Source Credentials:

Connect-PowerBIServiceAccount

 

$accesstoken = Get-PowerBIAccessToken

 

$patchBody = '"credentialDetails": {

   "credentials": {"accessToken":"'+$($accesstoken)+'"},

    "encryptedConnection": "Encrypted",

   "encryptionAlgorithm": "None",

  "privacyLevel": "Organizational",

    "useEndUserOAuth2Credentials": true

}'

 

Invoke-PowerBIRestMethod -Url "https://api.powerbi.com/v1.0/myorg/gateways/9eaed562-e9c2-46e4-91cf-276ed0947b41/datasources/f1181856-de29-4a9a-a555-a0e181cd7898" -Method Patch -Body $patchBody  

 

We would greatly appreciate any guidance or suggestions on resolving this error in the PowerShell scripting process for updating the Data Source Credentials.

 

Thanks!

Inogic Professional Services: Power Platform/Dynamics 365 CRM
An expert technical extension for your techno-functional business needs
Drop an email at email address removed for privacy reasons 
Service: https://www.inogic.com/services/ 
Tips and Tricks: https://www.inogic.com/blog/ 

1 Reply

Resources