Reputation: 109
I have 2 simple routes in my WebApiConfig:
config.Routes.MapHttpRoute(
name: "Speaker",
routeTemplate: "api/presentations/{presentationid}/speakers/{id}",
defaults: new { controller = "speakers", id = RouteParameter.Optional }
);
config.Routes.MapHttpRoute(
name: "Presentations",
routeTemplate: "api/presentations/{id}",
defaults: new { controller = "presentations", id = RouteParameter.Optional }
);
I can't get the first route to work.. I have a SpeakersController with a Get:
IEnumerable<SpeakerModel> Get(int presentationid)
{
return _speakerService.GetSpeakersByPresentationId(presentationid).Select(s => _modelFactory.Create(s));
}
And when I call : http://localhost/Api/Presentations/1/Speakers via a get request I get this error :
"Message": "No HTTP resource was found that matches the request URI 'http://localhost/Api/Presentations/1/Speakers'.", "MessageDetail": "No action was found on the controller 'Speakers' that matches the request."
Upvotes: 0
Views: 525
Reputation: 109
I did not have a public access modifier on my method.
**public** IEnumerable<SpeakerModel> Get(int presentationid)
{
return _speakerService.GetSpeakersByPresentationId(presentationid).Select(s => _modelFactory.Create(s));
}
Upvotes: 0