<?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 Setting PBI report policies with .Net OData client in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Setting-PBI-report-policies-with-Net-OData-client/m-p/2113382#M32278</link>
    <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In our company we have a lot of reports with a dozens of users, therefore we would like to automate the policy setting with a small .Net application in VS2019. First I configured a connected service with ,,OData Connected Service'' extension in the project. That works fine until a try to load the policies for a specific report, but in the last step a recieve an error message: ,,A property with name 'Id' was found when reading a top-level resource set. No properties other than the resource set property with name 'value' are allowed.''&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;using System;
using System.Linq;
using Model; // this is the namespace of the automatically generated OData client

namespace ODataTest
{
    class Program
    {
        static void Main(string[] args)
        {
            var context = new Container(new Uri("https://my.company.com/Reports/api/v2.0"));

            context.Credentials = System.Net.CredentialCache.DefaultCredentials;

            PowerBIReport ci = context.PowerBIReports.Where(c =&amp;gt; c.Path.Contains("SampleReport")).Single();
            context.LoadProperty(ci, "Policies"); // ERROR
        }
    }
}&lt;/LI-CODE&gt;&lt;P&gt;the last line throws the error. I also tried the ,,expand'' method but it is not working with the report servers API.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my understanding the a LoadProperty command expects a json response like&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
    "values":[
    {
      "GroupUserName":"DOMAIN\User1","Roles":[
        {
          "Name":"Content Manager","Description":null
        }
      ]
    }, ....
    ]
}&lt;/LI-CODE&gt;&lt;P&gt;however the a server send a response like this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
"@odata.context":"https://my.company.com/Reports/api/v2.0/$metadata#Collection(Model.ItemPolicy)",
    "Id":"00000000-0000-0000-0000-000000000000",
    "InheritParentPolicy":true,
    "Policies":[
    {
      "GroupUserName":"DOMAIN\User1","Roles":[
        {
          "Name":"Content Manager","Description":null
        }
      ]
    }, ....
    ]
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can You help to solve this issue? Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;best,&lt;/P&gt;&lt;P&gt;Gallusz&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;p.s.: as a last resort I can do policy setting with pure put request, but I think the proper way is to use the OData client library with the connected service&lt;/P&gt;</description>
    <pubDate>Mon, 04 Oct 2021 09:32:03 GMT</pubDate>
    <dc:creator>abaligetig</dc:creator>
    <dc:date>2021-10-04T09:32:03Z</dc:date>
    <item>
      <title>Setting PBI report policies with .Net OData client</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Setting-PBI-report-policies-with-Net-OData-client/m-p/2113382#M32278</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In our company we have a lot of reports with a dozens of users, therefore we would like to automate the policy setting with a small .Net application in VS2019. First I configured a connected service with ,,OData Connected Service'' extension in the project. That works fine until a try to load the policies for a specific report, but in the last step a recieve an error message: ,,A property with name 'Id' was found when reading a top-level resource set. No properties other than the resource set property with name 'value' are allowed.''&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;using System;
using System.Linq;
using Model; // this is the namespace of the automatically generated OData client

namespace ODataTest
{
    class Program
    {
        static void Main(string[] args)
        {
            var context = new Container(new Uri("https://my.company.com/Reports/api/v2.0"));

            context.Credentials = System.Net.CredentialCache.DefaultCredentials;

            PowerBIReport ci = context.PowerBIReports.Where(c =&amp;gt; c.Path.Contains("SampleReport")).Single();
            context.LoadProperty(ci, "Policies"); // ERROR
        }
    }
}&lt;/LI-CODE&gt;&lt;P&gt;the last line throws the error. I also tried the ,,expand'' method but it is not working with the report servers API.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my understanding the a LoadProperty command expects a json response like&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
    "values":[
    {
      "GroupUserName":"DOMAIN\User1","Roles":[
        {
          "Name":"Content Manager","Description":null
        }
      ]
    }, ....
    ]
}&lt;/LI-CODE&gt;&lt;P&gt;however the a server send a response like this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
"@odata.context":"https://my.company.com/Reports/api/v2.0/$metadata#Collection(Model.ItemPolicy)",
    "Id":"00000000-0000-0000-0000-000000000000",
    "InheritParentPolicy":true,
    "Policies":[
    {
      "GroupUserName":"DOMAIN\User1","Roles":[
        {
          "Name":"Content Manager","Description":null
        }
      ]
    }, ....
    ]
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can You help to solve this issue? Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;best,&lt;/P&gt;&lt;P&gt;Gallusz&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;p.s.: as a last resort I can do policy setting with pure put request, but I think the proper way is to use the OData client library with the connected service&lt;/P&gt;</description>
      <pubDate>Mon, 04 Oct 2021 09:32:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Setting-PBI-report-policies-with-Net-OData-client/m-p/2113382#M32278</guid>
      <dc:creator>abaligetig</dc:creator>
      <dc:date>2021-10-04T09:32:03Z</dc:date>
    </item>
    <item>
      <title>Re: Setting PBI report policies with .Net OData client</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Setting-PBI-report-policies-with-Net-OData-client/m-p/2121044#M32279</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/199726"&gt;@abaligetig&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't know much about this. Just provide some troubleshooting directions:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Please break out and get the returned result of "context";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2.&amp;nbsp; Please check the report property used ("SampleReport") is the same as it shows in PBIRS and test with others.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. Which&amp;nbsp;&lt;SPAN&gt;.Net OData client are you using? Are there any updates and changes?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Icey&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If this post&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;helps&lt;/STRONG&gt;&lt;SPAN&gt;, then please consider&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;&lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt;&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Oct 2021 08:51:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Setting-PBI-report-policies-with-Net-OData-client/m-p/2121044#M32279</guid>
      <dc:creator>Icey</dc:creator>
      <dc:date>2021-10-07T08:51:10Z</dc:date>
    </item>
  </channel>
</rss>

