locked
SSRS REST API - Error creating Subscription RRS feed

  • Question

  • Hi, I'm trying to create a subscription by using the 2017 REST API but can't get it to work. I've also tried by creating a subscription using the web portal, retrieving it with the REST API (which works fine) and then just changed the ID and posted it to the subscription-method:
    http://localhost/reports/api/v2.0/subscriptions

    The error I get in the response is "500 internal server error" but the message is empty:
    {

        "error": {
            "code": "",
            "message": ""
        }
    }

    Request body:
    {

      "Id": "bf2d18b0-569e-484c-8bcf-b1c0a0b824b6",
      "Owner": "username",
      "IsDataDriven": false,
      "Description": "MySubscription",
      "Report": "/Test/TestReport2",
      "IsActive": true,
      "EventType": "TimedSubscription",
      "ScheduleDescription": "At 2:00 AM every day, starting 2/22/2018",
      "LastStatus": "New Subscription",
      "DeliveryExtension": "Report Server FileShare",
      "LocalizedDeliveryExtensionName": "Windows File Share",
      "ModifiedBy": "username",
      "ModifiedDate": "2018-02-22T09:42:05.257Z",
      "ParameterValues": []
    }


    Any ideas what i'm doing wrong?
    Thank you.

    Thursday, February 22, 2018 2:01 PM

All replies

  • Hi,

    The 500 Internal Server Error is a very general HTTP status code that means something has gone wrong on the website's server, but the server could not be more specific on what the exact problem is.

    the 500 Internal Server Error is a server-side error, meaning the problem probably isn't with your computer or internet connection but instead with the website's server.

    While not probable, it is possible that there's something wrong on your end, in which case we'll look at some things you can try:

    1. Reload the web page. You can do that by clicking the refresh/reload button, pressing F5 or Ctrl-R, or trying the URL again from the address bar.

    Even if the 500 Internal Server Error is a problem on the web server, the issue might just be temporary. Trying the page again will often be successful.

    2. Clear your browser's cache. If there's a problem with the cached version of the page you're viewing, it could be causing HTTP 500 issues.

    And you need to follow the syntax in this article when using Rest API: https://docs.microsoft.com/en-us/sql/reporting-services/developer/rest-api

    BR,
    Henry 

    Friday, February 23, 2018 1:59 AM
  • Hi,

    We are exploring the SSRS Rest API for creating subscriptions, but have some problems, hope you can help us.

    First we need to create a subscription with eventtype = “TimedSubscription”.

    With this type we need to specify a schedule for the subscription as we understand.

    But we can’t figure out where to specify the schedule, we can’t find a property for this in the Subscription model parameter for /Subscriptions.

    AddSubscription Specification from swaggerhub:

    https://app.swaggerhub.com/apis/microsoft-rs/SSRS/2.0#/Subscriptions/AddSubscription

    Subscription{

    description:

    An object that defines a subscription. A Reporting Services subscription allows a user to subscribe to a Report or Data Source and then to automatically receive an update whenever the item is updated.

    Id

    string($uuid)example: 01234567-89ab-cdef-0123-456789abcdef

    A unique UUID value that specifies the identifier by which this Subscription can be referenced in requests or in other defined objects.

    Owner

    string($string)

    A string value that specifies the owner of the Subscription.

    IsDataDriven

    boolean($true|false)

    A boolean value that specifies whether the members of the distribution list for the subscription are computed based on data.

    Description

    string($string)

    A string value that contains descriptive text about the Subscription.

    Report

    string($string)

    A string value that specifies the path of the report for this Subscription.

    IsActive

    boolean($true|false)

    A boolean value that specifies whether the Subscription is currently active.

    EventType

    string($string)

    A string specifying the type of event that triggers the Subscription.

    ScheduleDescription

    string($string)

    A string value that contains descriptive text about the schedule referenced in the Schedule property.

    LastRunTime

    string($date-time)example: 2017-04-13T15:51:04Z

    A string value that contains the date-time that the schedule was last run.

    LastStatus

    string($string)

    A string specifying the Status of the last run.

    ExtensionSettings

    ExtensionSettings{...}

    DeliveryExtension

    string($string)

    An object that specifies the DeliveryExtension that will be used with this Schedule’s report delivery.

    LocalizedDeliveryExtensionName

    string($string)

    Localized version of extension name when available.

    ModifiedBy

    string($string)

    A string value that contains the network user name of the last user to modify the subscription.

    ModifiedDate

    string($date-time)example: 2017-04-13T15:51:04Z

    A string value that contains the date-time of the last modification to the subscription.

    ParameterValues

    [...]

    }

    We tried to create a subscription of type “TimedSubscription” without specifying the Schedule and then we get the following error in the RSPortal log file:

    RSPortal!reportserverwebapp!RSPortal.exe!1a!03/01/2018-10:44:03:: e ERROR: OData exception occurred: System.NullReferenceException: Object reference not set to an instance of an object.

       at Microsoft.ReportingServices.Portal.Repositories.SubscriptionService.GetMatchData(Subscription subscription)

       at Microsoft.ReportingServices.Portal.Repositories.SubscriptionService.CreateSubscription(IPrincipal userPrincipal, Subscription subscription)

       at Microsoft.ReportingServices.Portal.ODataWebApi.V2.Controllers.SubscriptionsController.AddEntity(Subscription entity)

       at Microsoft.ReportingServices.Portal.ODataWebApi.Controllers.Reflection.EntitySetReflectionODataController`1.Post(ODataPath oDataPath, T value)

       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_006e0c93-55a9-4fb8-8fea-e3c35be6de77

    We also tried to create a subscription of type “SnapshotUpdated” to see if we could create a subscription without needing to specify any schedule information.

    Then we don’t get any error in the RSPortal log file, but in the response we get following error:

    Hope you can help us, we really need to be able to create subscriptions of both types from our application.

    Thanks!

    Best regards Mathias

    Thursday, March 8, 2018 2:28 PM
  • Jimie, I found my own error:

    I was using the JSON emitted by an API call to GET a current subscription as a template for the 

    CREATE method. You have to use the -DEPTH parameter of convertTo-JSON in Powershell or you will get this incorrectly formatted JSON

    "ExtensionSettings":  {
                                  "Extension":  "Report Server Email",
                                  "ParameterValues":  [
                                                          "@{Name=TO; Value=user@company.com; IsValueFieldReference=False}",
                                                          "@{Name=IncludeReport; Value=True; IsValueFieldReference=False}",
                                                          "@{Name=RenderFormat; Value=MHTML; IsValueFieldReference=False}",
                                                          "@{Name=Subject; Value=@ReportName was executed at @ExecutionTime; IsValueFieldReference=False}",
                                                          "@{Name=IncludeLink; Value=True; IsValueFieldReference=False}",
                                                          "@{Name=Priority; Value=NORMAL; IsValueFieldReference=False}"
                                                      ]
                              },

    This is correct:

     "ExtensionSettings":  {
                                  "Extension":  "Report Server Email",
                                  "ParameterValues":  [
                                                        {
                                                            "Name":"TO","Value":"user@company.com","IsValueFieldReference":false
                                                        },
    
                                                        {
                                                            "Name":"IncludeReport","Value":"True","IsValueFieldReference":false
                                                        },
    
                                                        {
                                                            "Name":"RenderFormat","Value":"MHTML","IsValueFieldReference":false
                                                        },
    
                                                        {
                                                            "Name":"Subject","Value":"@ReportName was executed at @ExecutionTime","IsValueFieldReference":false
                                                        },
    
                                                        {
                                                            "Name":"IncludeLink","Value":"True","IsValueFieldReference":false
                                                        },
    
                                                        {
                                                            "Name":"Priority","Value":"NORMAL","IsValueFieldReference":false
                                                        }
                                                      ]
                              },



    • Edited by bytehd Friday, April 6, 2018 5:45 PM
    Thursday, April 5, 2018 4:39 PM