I would like to add some web api to my project but I am getting error that No HTTP resource was found that matches the request URI
What I could miss in settings or how I can see all sitecore routs and test it ?
{"Message":"No HTTP resource was found that matches the request URI 'http://my.local/rrapi/My/GetSometing'.","MessageDetail":"No type was found that matches the controller named 'methodName'."}
It seems like I did all settings
MyController
[ServicesController]
public class MyController : ServicesApiController
{
[HttpGet]
public IHttpActionResult GetSometing(string code)
{
return Ok("Done");
}
}
RegisterWebApiRoutes
public class RegisterWebApiRoutes
{
public void Process(PipelineArgs args)
{
RegisterRoutes(RouteTable.Routes, args);
}
private void RegisterRoutes(RouteCollection routes, PipelineArgs args)
{
if (routes["MyName.WebApi.Default"] != null)
{
Log.Warn("Route 'MyName.WebApi.Default' has already been added. Ensure only a single route processor for MyName WebApi.", this);
return;
}
routes.MapHttpRoute("MyName.WebApi.Default", "rrapi/{controller}/{action}/{code}", new
{
code = RouteParameter.Optional
}
//,
// new
// {
// httpMethod = new HttpMethodConstraint("Get", "Post", "Delete")
// }
);
Log.Info("Route 'MyName.WebApi.Default' has registered.", this);
}
}
Configuration Patch
<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<api>
<services>
<configuration>
<allowedControllers hint="list:AddController">
<allowedController desc="MyController">MyNameSpace.MyController , MyAssmbly</allowedController>
</allowedControllers>
</configuration>
</services>
</api>
<pipelines>
<initialize>
<processor type="MyNameSpace.RegisterWebApiRoutes, MyAssmbly" patch:before="processor[@type='Sitecore.Mvc.Pipelines.Loader.InitializeRoutes, Sitecore.Mvc']" />
</initialize>
</pipelines>
</sitecore>
</configuration>
ServicesController
attribute from the controller? That could be conflicting with your regular routing.