<?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 Re: ERROR 0 when trying update policies using API in Report Server</title>
    <link>https://community.fabric.microsoft.com/t5/Report-Server/ERROR-0-when-trying-update-policies-using-API/m-p/766590#M11289</link>
    <description>&lt;P&gt;solved!&lt;/P&gt;&lt;P&gt;The body must be a string ))&lt;/P&gt;</description>
    <pubDate>Wed, 14 Aug 2019 14:33:14 GMT</pubDate>
    <dc:creator>dmitry_onyschen</dc:creator>
    <dc:date>2019-08-14T14:33:14Z</dc:date>
    <item>
      <title>ERROR 0 when trying update policies using API</title>
      <link>https://community.fabric.microsoft.com/t5/Report-Server/ERROR-0-when-trying-update-policies-using-API/m-p/766214#M11286</link>
      <description>&lt;P&gt;I receive error&amp;nbsp;{"error": {"code": "0","message": ""}}&lt;/P&gt;&lt;P&gt;when trying to update policies for PowerBIReports or Folders using API (PUT-request)&lt;/P&gt;&lt;P&gt;I am trying to use:&lt;/P&gt;&lt;P&gt;* python&amp;nbsp;requests module&lt;/P&gt;&lt;P&gt;* python&amp;nbsp;urllib.request&lt;/P&gt;&lt;P&gt;* PowerShell&lt;/P&gt;&lt;P&gt;* Postman&lt;/P&gt;&lt;P&gt;but the result is the same. In this tyme GET and POST requests working correctly in all cases&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help me solve this problem!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example here is my PowerShell script:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;$username = "bi\Dmitry.on"
$password = "######"
$userpass  = $username + ":" + $password
$bytes= [System.Text.Encoding]::UTF8.GetBytes($userpass)
$encodedlogin=[Convert]::ToBase64String($bytes)
$authheader = "Basic " + $encodedlogin
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Authorization",$authheader)
$headers.Add("Accept","application/json")
$headers.Add("Content-Type","application/json")
$uri = "http://#######/Reports/api/v2.0/Folders(3c07816e-83a1-4145-904a-b0fd5e92511f)/Policies"

$data_json = '[{"InheritParentPolicy": false,
"Policies": [  {"GroupUserName": "bi\\Dmitry.on","Roles": [  {"Name": "Content Manager", "Description": "May manage content in the Report Server. This includes folders, reports and resources."
  }] }]}]'

$data_converted = ConvertFrom-Json –InputObject $data_json
$response = Invoke-RestMethod -Uri $uri -Headers $headers -Method PUT -Body $data_converted
Write-Host $response&lt;/PRE&gt;&lt;P&gt;Here is part of my python script:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;headers = {'Content-Type': 'multipart/form-data', 'accept': 'application/json'}
data = [
  {"InheritParentPolicy": False,
    "Policies": [
      {"GroupUserName": "bi\\dmitry.on",
        "Roles": [
          {"Name": "Content Manager",
            "Description": "May manage content in the Report Server. This includes folders, reports and resources."
          }]}]}]

v_result = s.put(url, headers=headers, data=data)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here are errors in RSPortal log:&lt;/P&gt;&lt;PRE&gt;2019-08-14 08:26:22.9937|INFO|18|Received request PUT /api/v2.0/Folders%283c07816e-83a1-4145-904a-b0fd5e92511f%29/Policies| RequestID = s_224a6a4f-8d65-433f-9ffe-0e9fa0feac78 
2019-08-14 08:26:23.2124|ERROR|18|OData exception occurred: System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.ReportingServices.Portal.Repositories.CatalogItemRepository.SetItemPolicy(IPrincipal userPrincipal, String itemPath, ItemPolicy itemPolicy)
   at Microsoft.ReportingServices.Portal.ODataWebApi.V2.Controllers.CatalogItemController`1.PutPolicies(String key, ItemPolicy policies)
   at lambda_method(Closure , Object , Object[] )
   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.&amp;lt;&amp;gt;c__DisplayClass10.&amp;lt;GetExecutor&amp;gt;b__9(Object instance, Object[] methodParameters)
   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Controllers.ApiControllerActionInvoker.&amp;lt;InvokeActionAsyncCore&amp;gt;d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Controllers.ActionFilterResult.&amp;lt;ExecuteAsync&amp;gt;d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Controllers.ExceptionFilterResult.&amp;lt;ExecuteAsync&amp;gt;d__0.MoveNext().| RequestID = s_224a6a4f-8d65-433f-9ffe-0e9fa0feac78 
2019-08-14 08:26:23.2124|INFO|34|Sending response. Response code bi\dmitry.on 500, Elapsed time 0:00:00,2127784| RequestID = s_224a6a4f-8d65-433f-9ffe-0e9fa0feac78 
2019-08-14 08:47:49.9665|INFO|22|Received request PUT /api/v2.0/Folders%283c07816e-83a1-4145-904a-b0fd5e92511f%29/Policies| RequestID = s_de6ece1b-e316-4f59-a2c9-60cec432f884 
2019-08-14 08:47:50.0446|ERROR|22|OData exception occurred: System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.ReportingServices.Portal.Repositories.CatalogItemRepository.SetItemPolicy(IPrincipal userPrincipal, String itemPath, ItemPolicy itemPolicy)
   at Microsoft.ReportingServices.Portal.ODataWebApi.V2.Controllers.CatalogItemController`1.PutPolicies(String key, ItemPolicy policies)
   at lambda_method(Closure , Object , Object[] )
   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.&amp;lt;&amp;gt;c__DisplayClass10.&amp;lt;GetExecutor&amp;gt;b__9(Object instance, Object[] methodParameters)
   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Controllers.ApiControllerActionInvoker.&amp;lt;InvokeActionAsyncCore&amp;gt;d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Controllers.ActionFilterResult.&amp;lt;ExecuteAsync&amp;gt;d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Controllers.ExceptionFilterResult.&amp;lt;ExecuteAsync&amp;gt;d__0.MoveNext().| RequestID = s_de6ece1b-e316-4f59-a2c9-60cec432f884 
2019-08-14 08:47:50.0446|INFO|22|Sending response. Response code bi\Dmitry.on 500, Elapsed time 0:00:00.0770578| RequestID = s_de6ece1b-e316-4f59-a2c9-60cec432f884 
2019-08-14 08:52:28.9726|INFO|60|Received request GET /api/v2.0/Folders| RequestID = s_15d2dbfe-0ea1-4285-928a-cddfd19e8aad 
2019-08-14 08:52:29.0833|INFO|58|Sending response. Response code bi\dmitry.on 200, Elapsed time 0:00:00.1049904| RequestID = s_15d2dbfe-0ea1-4285-928a-cddfd19e8aad 
2019-08-14 08:52:29.3646|INFO|60|Received request PUT /api/v2.0/Folders%283c07816e-83a1-4145-904a-b0fd5e92511f%29/Policies| RequestID = s_c4811470-9c60-4b34-b7a5-7a35e50da757 
2019-08-14 08:52:29.3958|ERROR|60|OData exception occurred: System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.ReportingServices.Portal.Repositories.CatalogItemRepository.SetItemPolicy(IPrincipal userPrincipal, String itemPath, ItemPolicy itemPolicy)
   at Microsoft.ReportingServices.Portal.ODataWebApi.V2.Controllers.CatalogItemController`1.PutPolicies(String key, ItemPolicy policies)
   at lambda_method(Closure , Object , Object[] )
   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.&amp;lt;&amp;gt;c__DisplayClass10.&amp;lt;GetExecutor&amp;gt;b__9(Object instance, Object[] methodParameters)
   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Controllers.ApiControllerActionInvoker.&amp;lt;InvokeActionAsyncCore&amp;gt;d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Controllers.ActionFilterResult.&amp;lt;ExecuteAsync&amp;gt;d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Controllers.ExceptionFilterResult.&amp;lt;ExecuteAsync&amp;gt;d__0.MoveNext().| RequestID = s_c4811470-9c60-4b34-b7a5-7a35e50da757 
2019-08-14 08:52:29.3958|INFO|62|Sending response. Response code bi\dmitry.on 500, Elapsed time 0:00:00.0270003| RequestID = s_c4811470-9c60-4b34-b7a5-7a35e50da757 &lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Aug 2019 08:59:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Report-Server/ERROR-0-when-trying-update-policies-using-API/m-p/766214#M11286</guid>
      <dc:creator>dmitry_onyschen</dc:creator>
      <dc:date>2019-08-14T08:59:30Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 0 when trying update policies using API</title>
      <link>https://community.fabric.microsoft.com/t5/Report-Server/ERROR-0-when-trying-update-policies-using-API/m-p/766590#M11289</link>
      <description>&lt;P&gt;solved!&lt;/P&gt;&lt;P&gt;The body must be a string ))&lt;/P&gt;</description>
      <pubDate>Wed, 14 Aug 2019 14:33:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Report-Server/ERROR-0-when-trying-update-policies-using-API/m-p/766590#M11289</guid>
      <dc:creator>dmitry_onyschen</dc:creator>
      <dc:date>2019-08-14T14:33:14Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 0 when trying update policies using API</title>
      <link>https://community.fabric.microsoft.com/t5/Report-Server/ERROR-0-when-trying-update-policies-using-API/m-p/1468748#M16483</link>
      <description>&lt;P&gt;Sorry but I'm getting the exact same error and still couldn't solve it. I'm doing the PUT request this way:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;object[] oArr = new object[] {
    new {
        InheritParentPolicy = inheritParentPolicy
    }
};
RestRequest request = new RestRequest(string.Format("/Folders({0})/Policies", itemId), Method.PUT);
request.RequestFormat = DataFormat.Json;
request.AddJsonBody(oArr);
IRestResponse response = _client.Execute(request);&lt;/LI-CODE&gt;&lt;P&gt;It's not an Authentication issue or something related as I'm already doing other GET, POST and PUT requests and all is working fin.&lt;/P&gt;&lt;P&gt;Any ideas? Thanks a lot!!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Nov 2020 07:56:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Report-Server/ERROR-0-when-trying-update-policies-using-API/m-p/1468748#M16483</guid>
      <dc:creator>cari_mendez</dc:creator>
      <dc:date>2020-11-02T07:56:01Z</dc:date>
    </item>
  </channel>
</rss>

