Calling APIController

Stimulsoft Reports.ANGULAR discussion
Post Reply
ChrisChen
Posts: 2
Joined: Fri Oct 21, 2022 12:26 am

Calling APIController

Post by ChrisChen »

Hi,

I am trying to using Angular report with ApiController OWIN server.

below is my ApiController code, the only difference between sample code and mine is the controller inherits from ApiController, not Controller

Code: Select all


    public class BalanceSheetViewerController : ApiController
    {
        private readonly IBalanceSheetLogic logic;
        private readonly ICompInfoLogic compInfoLogic;

        public BalanceSheetViewerController(
            IBalanceSheetLogic logic,
            ICompInfoLogic compInfoLogic
        )
        {
            this.logic = logic;
            this.compInfoLogic = compInfoLogic;
        }

        [System.Web.Http.HttpPost]
        [AllowCrossSiteJson]
        public ActionResult InitViewer()
        {
            var requestParams = StiAngularViewer.GetRequestParams();
            var options = new StiAngularViewerOptions();
            options.Actions.GetReport = "GetReport";
            options.Actions.ViewerEvent = "ViewerEvent";
            options.Appearance.ScrollbarsMode = true;

            return StiAngularViewer.ViewerDataResult(requestParams, options);
        }
        ......
        

everything looks good until running it. when the client angular runs receive the error from
return StiAngularViewer.ViewerDataResult(requestParams, options)
the error is
Object reference not set to an instance of an object.
and below is the call stacks

Code: Select all

   at Stimulsoft.Report.Web.StiCacheHelper.GetObject(String guid)
   at Stimulsoft.Report.Web.StiCacheHelper.GetResource(String guid)
   at Stimulsoft.Report.Web.StiViewerResourcesHelper.GetStyles(StiRequestParams requestParams)
   at Stimulsoft.Report.Angular.StiAngularViewer.ViewerDataResult(StiRequestParams requestParams, StiAngularViewerOptions options)
   at Beyond.API.Controllers.BalanceSheetViewerController.InitViewer() in BalanceSheetViewerController.cs:line 42
   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass6_2.<GetExecutor>b__2(Object instance, Object[] methodParameters)
   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)
Could you help with this?
Thanks!
Lech Kulikowski
Posts: 4969
Joined: Tue Mar 20, 2018 5:34 am

Re: Calling APIController

Post by Lech Kulikowski »

Hello,

We need some additional time to investigate the issue, we will let you know about the result.

Thank you.
Vadim
Posts: 325
Joined: Tue Apr 23, 2013 11:23 am

Re: Calling APIController

Post by Vadim »

Hello.

Please try options.Server.CacheMode = StiServerCacheMode.StringCache;
ChrisChen
Posts: 2
Joined: Fri Oct 21, 2022 12:26 am

Re: Calling APIController

Post by ChrisChen »

Vadim wrote: Wed Oct 26, 2022 7:31 am Hello.

Please try options.Server.CacheMode = StiServerCacheMode.StringCache;
Hi, it's still got the null reference error.

Thanks
Lech Kulikowski
Posts: 4969
Joined: Tue Mar 20, 2018 5:34 am

Re: Calling APIController

Post by Lech Kulikowski »

Hello,

Please clarify which version are you use?

Thank you.
Post Reply