cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dmitry_onyschen Frequent Visitor
Frequent Visitor

ERROR 0 when trying update policies using API

I receive error {"error": {"code": "0","message": ""}}

when trying to update policies for PowerBIReports or Folders using API (PUT-request)

I am trying to use:

* python requests module

* python urllib.request

* PowerShell

* Postman

but the result is the same. In this tyme GET and POST requests working correctly in all cases

 

Please help me solve this problem!

 

For example here is my PowerShell script:

 

$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

Here is part of my python script:

 

 

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)

 

 

Here are errors in RSPortal log:

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.<>c__DisplayClass10.<GetExecutor>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.<InvokeActionAsyncCore>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.<ExecuteAsync>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.<ExecuteAsync>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.<>c__DisplayClass10.<GetExecutor>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.<InvokeActionAsyncCore>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.<ExecuteAsync>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.<ExecuteAsync>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.<>c__DisplayClass10.<GetExecutor>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.<InvokeActionAsyncCore>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.<ExecuteAsync>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.<ExecuteAsync>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 
1 ACCEPTED SOLUTION

Accepted Solutions
dmitry_onyschen Frequent Visitor
Frequent Visitor

Re: ERROR 0 when trying update policies using API

solved!

The body must be a string ))

View solution in original post

1 REPLY 1
dmitry_onyschen Frequent Visitor
Frequent Visitor

Re: ERROR 0 when trying update policies using API

solved!

The body must be a string ))

View solution in original post

Helpful resources

Announcements
Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Analytics in Azure virtual event

Analytics in Azure virtual event

Experience a limitless analytics service built to ingest, prep, manage, and serve data for immediate use in Power BI.

Users Online
Currently online: 61 members 1,224 guests
Please welcome our newest community members: