report server api
1 TopicSetting 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 service927Views0likes1Comment