0

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

Sahil Sharma
  • 3,027
  • 3
  • 29
  • 71

1 Answers1

0

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
Mostafiz
  • 6,845
  • 3
  • 21
  • 37
  • in your controller I ma getting one parameter input but your error showing multiple parameter in url `'http://localhost/api/advantage/getDeals/?cityId=2&sc=0&so=1&pn=1'`, what is actual code one paramter or multiple ? – Mostafiz Aug 05 '16 at 11:43
  • Its actually multiple. but to simplify i had posted one parameter. Changed both now. – Sahil Sharma Aug 05 '16 at 11:44
  • This is action method now: [Route("api/adxxx/getDeals/{input}")] public IHttpActionResult GetDeals(int input) and this is what i hit from postman: http://localhost/api/adxxx/getDeals/2. But i get IIS 10.0 Detailed Error - 404.0 - Not Found error. – Sahil Sharma Aug 05 '16 at 11:52
  • do you have any port number in localhost like `http://localhost:8080` ? – Mostafiz Aug 05 '16 at 11:55
  • Port should not be an issue. Since other apis in same project (other controller) are working fine. – Sahil Sharma Aug 05 '16 at 11:56