Not invoking WebApi

Topics: Core, Customizing Orchard
Jun 14 at 1:20 PM
Edited Jun 14 at 1:52 PM
Hi,

I have created one Web API Controller and created one custom route, but it's not invoking at run time

This is my code:

Controller
using Orchard;
using Orchard.ContentManagement;
using Orchard.Localization;
using Syncfusion.EJ.ReportViewer;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace TestModules.Controllers
{
    public class TestApiController : ApiController, IReportController
    {
        public TestApiController(
        IOrchardServices orchardServices)
        {
            Services = orchardServices;
            T = NullLocalizer.Instance;
        }

        public IOrchardServices Services { get; private set; }
        public Localizer T { get; set; }

        //Post action for processing the rdl/rdlc report
        [System.Web.Http.ActionName("PostReportAction")]
        [AcceptVerbs("POST")]
        public object PostReportAction(Dictionary<string, object> jsonResult)
        {
            return ReportHelper.ProcessReport(jsonResult, this);
        }

        //Get action for getting resources from the report
        [System.Web.Http.ActionName("GetResource")]
        [AcceptVerbs("GET")]
        public object GetResource(string key, string resourcetype, bool isPrint)
        {
            return ReportHelper.GetResource(key, resourcetype, isPrint);
        }

        //Method will be called when initialize the report options before start processing the report
        public void OnInitReportOptions(ReportViewerOptions reportOption)
        {
            //You can update report options here
        }

        //Method will be called when reported is loaded
        public void OnReportLoaded(ReportViewerOptions reportOption)
        {
            //You can update report options here
        }
}
}
Custom Route
using System.Collections.Generic;
using Orchard.Mvc.Routes;
using System.Web.Routing;
using System.Web.Mvc;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.Http;
using Orchard.WebApi.Routes;

namespace TestModules
{
    public class HttpRoutes : IHttpRouteProvider
    {
        public void GetRoutes(ICollection<RouteDescriptor> routes)
        {
            foreach (RouteDescriptor routeDescriptor in GetRoutes())
            {
                routes.Add(routeDescriptor);
            }
        }

        public IEnumerable<RouteDescriptor> GetRoutes()
        {
            return new[] {
            new HttpRouteDescriptor {
                Name = "HelloApi",
                Priority = -10,
                RouteTemplate = "api/{controller}/{action}/{id}",
                Defaults = new {
                    id = System.Web.Http.RouteParameter.Optional,
                    area = "TestModules",
                    controller = "TestApi",
                    action = "PostReportAction"
                },
            }
        };
        }
    }
And in here GET method is working fine, but i need POST method(PostReportAction) for generating RDLC report

but in run time it's showing like this:
No HTTP resource was found that matches the request URI 'http://localhost:30321/OrchardLocal/api/TestApi/PostReportAction'.No controller was selected to handle this request.
With out PostReportAction the debugger has hitting the controller and showing result(http://localhost:30321/OrchardLocal/api/TestApi)

Thanking You,
Nitheesh