400 Bad Request for /api/reports/clients/{client_id}/parameters

3 posts, 0 answers
  1. Yegor
    Yegor avatar
    3 posts
    Member since:
    Jul 2012

    Posted 15 May 2014 Link to this post

    Hello,

    I am trying to use HTML5 Report Viewer with MVC extension helper.

    I have an error "Unable to get report parameters: Missing report name". It is happening during POST request to /api/reports/clients/210953-ab00/parameters which gets 400 Bad Request. 

    I guess because request data do not have report: parameterValues: {} report: null

    I call HTML helper like that:

        @(Html.TelerikReporting().ReportViewer()
            .Id("reportViewer1").ReportResolver(new TypeReportSourceResolver())
            .ServiceUrl("/api/reports/")
            .TemplateUrl(Url.Content("~/ReportViewer/templates/telerikReportViewerTemplate.html"))
            .ReportSource(new InstanceReportSource(){ReportDocument = new SessionReport()})
            .ViewMode(ViewModes.INTERACTIVE)
            .ScaleMode(ScaleModes.SPECIFIC)
            .Scale(1.0)
            .PersistSession(false)
        )

    I have my ReportController implemented like:

    public class ReportsController : ReportsControllerBase
        {
            protected override IReportResolver CreateReportResolver()
            {
                var reportsPath = HttpContext.Current.Server.MapPath("~/Reports");

                return new ReportFileResolver(reportsPath)
                    .AddFallbackResolver(new ReportTypeResolver());
            }

            protected override ICache CreateCache()
            {
                return Telerik.Reporting.Services.Engine.CacheFactory.CreateFileCache();
            }
        }

    And as I am using MVC5 with WepApi2 I have in my web.config following (I am not sure about last entry for Newtonsoft.Json):

          <dependentAssembly>
            <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0-5.1.0.0" newVersion="5.1.0.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0-5.1.0.0" newVersion="5.1.0.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0-4.5.0.0" newVersion="4.5.0.0" />
          </dependentAssembly>

    Can you help, please? Regards, Yegor.
  2. Stef
    Admin
    Stef avatar
    3036 posts

    Posted 16 May 2014 Link to this post

    Hello Yegor,

    The HTML5 Report Viewer is entirely HTML/CSS/JS based widget, which needs the ReportViewer-x.x.x.x.js(css) and telerikReportViewerTemplate.html template files to work. It also requires a running instance of the Telerik Reporting REST Service - the possible service's implementations are Web API and ServiceStack based. By default we provide 

    To create a Web application project that uses the viewer and the Reporting REST Web API for example,  follow the steps listed in the following articles:
    1.     How To: Use HTML5 Report Viewer extension in an ASP.NET MVC application
    2.     How To: Add Telerik Reporting REST Web API to Web Application


    Then if you need to make customizations over the reports, you can use a Custom Report Resolver. The string received by the resolver's Resolve method comes from the set viewer's reportSource.report option (use the HTML5 Report Viewer jQuery widget for the purpose).


    Regards,
    Stef
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. DevCraft banner
  4. Yegor
    Yegor avatar
    3 posts
    Member since:
    Jul 2012

    Posted 21 May 2014 in reply to Stef Link to this post

    Thank you!

    My problem was that I have not used TypeReportSource with proper AssemblyQualifiedName, which is hard to enter manually.

    Now to reduce hard-coding I use it like that:
    @{
            var reportSource = new TypeReportSource() { TypeName = typeof(SessionReport).AssemblyQualifiedName };
            reportSource.Parameters.Add("SessionId", Model);
       }
    @(Html.TelerikReporting().ReportViewer()
            .Id("reportViewer1")
            ...
            .ReportSource(reportSource)
            ...)
Back to Top