0
votes

When i am hitting the url: http://localhost/api/adxxx/getDeals/?input=2

I get the following error:

"Message": "No HTTP resource was found that matches the request URI 'http://localhost/api/adxxx/getDeals/?input=2'.",

"MessageDetail": "No type was found that matches the controller named 'adxxx'."

 public static class WebApiConfig
    {
        public static void Register(HttpConfiguration config)
        {        
            config.DependencyResolver = new UnityResolver(UnityBootstrapper.Initialise());
            config.EnableCors();

            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "xxx.services",
                routeTemplate: "webapi/{controller}/{action}"
            );

            config.Routes.MapHttpRoute(
               name: "xxx.services_new",
               routeTemplate: "api/{controller}/{action}",
               defaults: new { id = RouteParameter.Optional }
           );

           FluentValidationModelValidatorProvider.Configure(config);
        }
    }


[Route("api/adxxx/getDeals/")]
public IHttpActionResult GetDeals(int input)
{
 //code here
}

How do i resolve this? Very similar apis having different route are working fine.

This happened when i have added fluent validation to my api. That updated my System.Web.Http.dll to v5.2.3.0

1
do you have RoutePrefix attribute on your controller? if no? then you can move "api/adxxx" to controllers RoutePrefix and leave "getDeals" at method attribute ending slash looks suspicious also - Chizh
Do you have an advantageController? - Martin Brandl
sorry, wanted to mask the original names. forgot to change it in error message. edit done now. - Sahil Sharma

1 Answers

0
votes

Correct your route config for allow parameter

[Route("api/adxxx/getDeals/{input}")]
public IHttpActionResult GetDeals(int input)
{
 //code here
}

and then you can request it by

http://localhost/api/adxxx/getDeals/2