<?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 Update data model role assignment (RLS) of PBI report using Powershell in Report Server</title>
    <link>https://community.fabric.microsoft.com/t5/Report-Server/Update-data-model-role-assignment-RLS-of-PBI-report-using/m-p/3869802#M34708</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to dynamically update Row level security of power bi report that is deployed to PBIRS. I have used powershell script to get list of users in row level security but I could not find out how to update the list or add users to RLS.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here is the step that I have done:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;$PBIRSUrl = '&lt;A href="https://MyPBIRServer.com" target="_blank"&gt;https://MyPBIRServer.com&lt;/A&gt;'&lt;/P&gt;&lt;P&gt;#API to get role assignments&lt;BR /&gt;$reportRoles = $PBIRSUrl + "/PBIReports/api/v2.0/PowerBIReports(Path='/MyReport')/DataModelRoleAssignments"&lt;/P&gt;&lt;P&gt;#call API&lt;BR /&gt;$result = Invoke-RestMethod -Uri $reportRoles -ContentType "application/json" -UseDefaultCredentials -Method Get&lt;/P&gt;&lt;P&gt;#steps to update $result.value and add new user then save it to&amp;nbsp;$roleAssgnmtjson&lt;/P&gt;&lt;P&gt;$roleAssgnmtjson&amp;nbsp;&lt;/P&gt;&lt;P&gt;@{[&lt;BR /&gt;{&lt;BR /&gt;"GroupUserName": "domain\User001",&lt;BR /&gt;"DataModelRoles": ["2336b4a-e5b0-49ef-8556-62152375f005"]&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"GroupUserName": "domain\User002",&lt;BR /&gt;"DataModelRoles": ["2336b4a-e5b0-49ef-8556-62152375f005"]&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;]}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#API to update role assignments&lt;/P&gt;&lt;P&gt;Invoke-RestMethod -Uri $reportRoles -ContentType "application/json" -Body $roleAssgnmtjson -UseDefaultCredentials -Method Put&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Invoke-RestMethod : The remote server returned an error: (400) Bad Request.&lt;BR /&gt;At line:1 char:1&lt;BR /&gt;+ Invoke-RestMethod -Uri $reportRoles -ContentType "application/json" ...&lt;BR /&gt;+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&lt;BR /&gt;+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException&lt;BR /&gt;+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;does anyone know how to fix the issue?&lt;/P&gt;&lt;P&gt;I have also tried using&amp;nbsp;$resultjson for body of put request, but same error&lt;/P&gt;&lt;P&gt;$resultjson:&amp;nbsp;&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt;"@odata.context": "&lt;A href="https://MyPBIRServer.com/PBIReports/api/v2.0/$metadata#Collection(Model.DataModelRoleAssignment" target="_blank"&gt;https://MyPBIRServer.com/PBIReports/api/v2.0/$metadata#Collection(Model.DataModelRoleAssignment&lt;/A&gt;)",&lt;BR /&gt;"value": [&lt;BR /&gt;{&lt;BR /&gt;"GroupUserName": "domain\User001",&lt;BR /&gt;"DataModelRoles": "2336b4a-e5b0-49ef-8556-62152375f005"&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"GroupUserName": "domain\User002",&lt;BR /&gt;"DataModelRoles": "2336b4a-e5b0-49ef-8556-62152375f005"&lt;BR /&gt;}&lt;BR /&gt;]}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Fri, 26 Apr 2024 03:09:08 GMT</pubDate>
    <dc:creator>sarada</dc:creator>
    <dc:date>2024-04-26T03:09:08Z</dc:date>
    <item>
      <title>Update data model role assignment (RLS) of PBI report using Powershell</title>
      <link>https://community.fabric.microsoft.com/t5/Report-Server/Update-data-model-role-assignment-RLS-of-PBI-report-using/m-p/3869802#M34708</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to dynamically update Row level security of power bi report that is deployed to PBIRS. I have used powershell script to get list of users in row level security but I could not find out how to update the list or add users to RLS.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here is the step that I have done:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;$PBIRSUrl = '&lt;A href="https://MyPBIRServer.com" target="_blank"&gt;https://MyPBIRServer.com&lt;/A&gt;'&lt;/P&gt;&lt;P&gt;#API to get role assignments&lt;BR /&gt;$reportRoles = $PBIRSUrl + "/PBIReports/api/v2.0/PowerBIReports(Path='/MyReport')/DataModelRoleAssignments"&lt;/P&gt;&lt;P&gt;#call API&lt;BR /&gt;$result = Invoke-RestMethod -Uri $reportRoles -ContentType "application/json" -UseDefaultCredentials -Method Get&lt;/P&gt;&lt;P&gt;#steps to update $result.value and add new user then save it to&amp;nbsp;$roleAssgnmtjson&lt;/P&gt;&lt;P&gt;$roleAssgnmtjson&amp;nbsp;&lt;/P&gt;&lt;P&gt;@{[&lt;BR /&gt;{&lt;BR /&gt;"GroupUserName": "domain\User001",&lt;BR /&gt;"DataModelRoles": ["2336b4a-e5b0-49ef-8556-62152375f005"]&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"GroupUserName": "domain\User002",&lt;BR /&gt;"DataModelRoles": ["2336b4a-e5b0-49ef-8556-62152375f005"]&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;]}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#API to update role assignments&lt;/P&gt;&lt;P&gt;Invoke-RestMethod -Uri $reportRoles -ContentType "application/json" -Body $roleAssgnmtjson -UseDefaultCredentials -Method Put&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Invoke-RestMethod : The remote server returned an error: (400) Bad Request.&lt;BR /&gt;At line:1 char:1&lt;BR /&gt;+ Invoke-RestMethod -Uri $reportRoles -ContentType "application/json" ...&lt;BR /&gt;+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&lt;BR /&gt;+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException&lt;BR /&gt;+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;does anyone know how to fix the issue?&lt;/P&gt;&lt;P&gt;I have also tried using&amp;nbsp;$resultjson for body of put request, but same error&lt;/P&gt;&lt;P&gt;$resultjson:&amp;nbsp;&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt;"@odata.context": "&lt;A href="https://MyPBIRServer.com/PBIReports/api/v2.0/$metadata#Collection(Model.DataModelRoleAssignment" target="_blank"&gt;https://MyPBIRServer.com/PBIReports/api/v2.0/$metadata#Collection(Model.DataModelRoleAssignment&lt;/A&gt;)",&lt;BR /&gt;"value": [&lt;BR /&gt;{&lt;BR /&gt;"GroupUserName": "domain\User001",&lt;BR /&gt;"DataModelRoles": "2336b4a-e5b0-49ef-8556-62152375f005"&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"GroupUserName": "domain\User002",&lt;BR /&gt;"DataModelRoles": "2336b4a-e5b0-49ef-8556-62152375f005"&lt;BR /&gt;}&lt;BR /&gt;]}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2024 03:09:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Report-Server/Update-data-model-role-assignment-RLS-of-PBI-report-using/m-p/3869802#M34708</guid>
      <dc:creator>sarada</dc:creator>
      <dc:date>2024-04-26T03:09:08Z</dc:date>
    </item>
    <item>
      <title>Re: Update data model role assignment (RLS) of PBI report using Powershell</title>
      <link>https://community.fabric.microsoft.com/t5/Report-Server/Update-data-model-role-assignment-RLS-of-PBI-report-using/m-p/3873691#M34721</link>
      <description>&lt;P&gt;Issue here was about body of request.&amp;nbsp; I have tested the api using Postman and found out body of my resquest is not correct in PUT request. correct format of&amp;nbsp;&lt;/P&gt;&lt;P&gt;$roleAssgnmtjson:&lt;/P&gt;&lt;P&gt;[&lt;BR /&gt;{&lt;BR /&gt;"GroupUserName": "domain\User001",&lt;BR /&gt;"DataModelRoles": ["2336b4a-e5b0-49ef-8556-62152375f005"]&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"GroupUserName": "domain\User002",&lt;BR /&gt;"DataModelRoles": ["2336b4a-e5b0-49ef-8556-62152375f005"]&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;]&lt;BR /&gt;one point here is that 'DataModelRoles' is an array and I was trying to update that as text for new users:&amp;nbsp;{&lt;BR /&gt;"GroupUserName": "domain\User002",&lt;BR /&gt;"DataModelRoles": "2336b4a-e5b0-49ef-8556-62152375f005"&lt;BR /&gt;}&lt;BR /&gt;this was another issue that I didn't notice because I had only one row level security in my report.&amp;nbsp;&lt;BR /&gt;hope this help others with same issue&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2024 00:46:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Report-Server/Update-data-model-role-assignment-RLS-of-PBI-report-using/m-p/3873691#M34721</guid>
      <dc:creator>sarada</dc:creator>
      <dc:date>2024-04-29T00:46:06Z</dc:date>
    </item>
  </channel>
</rss>

