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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
abaligetig
Regular Visitor

Setting PBI report policies with .Net OData client

Hi!

 

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.''

 

Here is my code:

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 => c.Path.Contains("SampleReport")).Single();
            context.LoadProperty(ci, "Policies"); // ERROR
        }
    }
}

the last line throws the error. I also tried the ,,expand'' method but it is not working with the report servers API. 

 

In my understanding the a LoadProperty command expects a json response like

{
    "values":[
    {
      "GroupUserName":"DOMAIN\User1","Roles":[
        {
          "Name":"Content Manager","Description":null
        }
      ]
    }, ....
    ]
}

however the a server send a response like this:

{
"@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
        }
      ]
    }, ....
    ]
}

 

Can You help to solve this issue? Thanks!

 

best,

Gallusz

 

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

1 REPLY 1
Icey
Community Support
Community Support

Hi @abaligetig ,

 

I don't know much about this. Just provide some troubleshooting directions:

 

1. Please break out and get the returned result of "context";

 

2.  Please check the report property used ("SampleReport") is the same as it shows in PBIRS and test with others.

 

3. Which .Net OData client are you using? Are there any updates and changes?

 

 

Best Regards,

Icey

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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