vision10 / mssql-ssrs

Promise based api for MSSQL Reporting Services with ntlm, basic, custom security
22 stars 6 forks source link

Parameters not recognized when calling CreateSubscription #21

Open simonxuhao opened 1 year ago

simonxuhao commented 1 year ago

When using the following code to create subscription:

import {ReportService} from 'mssql-ssrs'

const rs = new ReportService()
await rs.start(
    'http://my-report-server/ReportServer',
    {
        username: 'xxxxxxxx',
        password: 'xxxxxxxx',
        domain: 'DEV'
    },
    {
        useRs2012: false
    },
    'ntlm'
)
const client = rs.getClient()

const Parameters = [
    {
        Name: 'report_request_id',
        Value: 100
    }
]

const args = {
    ItemPath: '/TEST/Reports/MyReportType',
    ExtensionSettings: {
        RENDER_FORMAT: 'PDF',
        FILENAME: 'my-test-report',
        FILEEXTN: true,
        PATH: '/Test/Reports/',
        WRITEMODE: 'Overwrite',
        AUTOCOPY: 'False'
    },
    Description: 'My test report',
    EventType: 'TimedSubscription ',
    MatchData: '<ScheduleDefinition>' +
        '   <StartDateTime>2003-02-24T09:00:00-08:00' +
        '   </StartDateTime>' +
        '   <WeeklyRecurrence>' +
        '      <WeeksInterval>1</WeeksInterval>' +
        '      <DaysOfWeek>' +
        '         <Monday>True</Monday>' +
        '      </DaysOfWeek>' +
        '   </WeeklyRecurrence>' +
        '</ScheduleDefinition>',
    Parameters: Parameters
}

console.log(client.CreateSubscription(args, function (err) {
    console.log(err.response.data)
}, null, null))

I always get the following error:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body>
    <soap:Fault>
      <faultcode>soap:Client</faultcode>
      <faultstring>This report requires a default or user-defined value for the report parameter report_request_id. To run or subscribe to this report, you must provide a parameter value. ---&gt; Microsoft.ReportingServices.Diagnostics.Utilities.ReportParameterValueNotSetException: This report requires a default or user-defined value for the report parameter report_request_id. To run or subscribe to this report, you must provide a parameter value.</faultstring>
      <faultactor>http://my-report-server/ReportServer/ReportService2010.asmx</faultactor>
      <detail>
        <ErrorCode xmlns="http://www.microsoft.com/sql/reportingservices">rsReportParameterValueNotSet</ErrorCode>
        <HttpStatus xmlns="http://www.microsoft.com/sql/reportingservices">400</HttpStatus>
        <Message xmlns="http://www.microsoft.com/sql/reportingservices">This report requires a default or user-defined value for the report parameter report_request_id. To run or subscribe to this report, you must provide a parameter value.</Message>
        <HelpLink xmlns="http://www.microsoft.com/sql/reportingservices">https://go.microsoft.com/fwlink/?LinkId=20476&amp;EvtSrc=Microsoft.ReportingServices.Diagnostics.Utilities.ErrorStrings&amp;EvtID=rsReportParameterValueNotSet&amp;ProdName=Microsoft%20SQL%20Server%20Reporting%20Services&amp;ProdVer=13.0.5026.0</HelpLink>
        <ProductName xmlns="http://www.microsoft.com/sql/reportingservices">Microsoft SQL Server Reporting Services</ProductName>
        <ProductVersion xmlns="http://www.microsoft.com/sql/reportingservices">13.0.5026.0</ProductVersion>
        <ProductLocaleId xmlns="http://www.microsoft.com/sql/reportingservices">127</ProductLocaleId>
        <OperatingSystem xmlns="http://www.microsoft.com/sql/reportingservices">OsIndependent</OperatingSystem>
        <CountryLocaleId xmlns="http://www.microsoft.com/sql/reportingservices">1033</CountryLocaleId>
        <MoreInformation xmlns="http://www.microsoft.com/sql/reportingservices">
          <Source>Microsoft.ReportingServices.ProcessingCore</Source>
          <Message xmlns:msrs="http://www.microsoft.com/sql/reportingservices" msrs:ErrorCode="rsReportParameterValueNotSet" msrs:HelpLink="https://go.microsoft.com/fwlink/?LinkId=20476&amp;EvtSrc=Microsoft.ReportingServices.Diagnostics.Utilities.ErrorStrings&amp;EvtID=rsReportParameterValueNotSet&amp;ProdName=Microsoft%20SQL%20Server%20Reporting%20Services&amp;ProdVer=13.0.5026.0">This report requires a default or user-defined value for the report parameter report_request_id. To run or subscribe to this report, you must provide a parameter value.</Message>
        </MoreInformation>
        <Warnings xmlns="http://www.microsoft.com/sql/reportingservices"/>
      </detail>
    </soap:Fault>
  </soap:Body>
</soap:Envelope>

The error message is: This report requires a default or user-defined value for the report parameter report_request_id. To run or subscribe to this report, you must provide a parameter value.

I also tried const Parameters = { report_request_id: 100 } but got the same error.

How can I specify this parameter when calling client.CreateSubscription()?

BTW, the readme mentioned ReportParameterInfo, where is it defined?

Nirator78 commented 1 month ago

Hello, First I thing you don't need to create XML in your json you can only use json. Then, you can find the complete documentation of the CreateSubscription just here with all parameter definition: https://learn.microsoft.com/fr-fr/dotnet/api/reportservice2010.reportingservice2010.createsubscription?view=sqlserver-2016#reportservice2010-reportingservice2010-createsubscription(system-string-reportservice2010-extensionsettings-system-string-system-string-system-string-reportservice2010-parametervalue())