0

Getting 404 after adding a new parameter itemGroup to the already working Web API 2 action. Not able to figure out what I did wrong.

Controller

[RoutePrefix("v2/calendar")]
public class CalendarController : ApiController

Action

[Route("list/{typeId:int}/{count:int}/{itemGroup:alpha?}/{startDate:DateTime?}")]
public List<CalendarItem> Calendar(int typeId, int count, string itemGroup = null, DateTime? startDate = null)
{
}

Client Call /v2/public/calendar/list?typeId=7&count=31&itemGroup=abc&startDate=10-20-2018

joym8
  • 4,014
  • 3
  • 50
  • 93
  • There are mulitple questions about this, see: https://www.google.com/search?q=web+api+multiple+optional+parameters+site:stackoverflow.com – Igor Nov 16 '18 at 19:40
  • Possible duplicate of [Optional Parameters in Web Api Attribute Routing](https://stackoverflow.com/questions/22778640/optional-parameters-in-web-api-attribute-routing) – Igor Nov 16 '18 at 19:40
  • Thanks for the pointer! "You really should use query strings for optional parameters and path parameters if they are required." https://stackoverflow.com/a/42115291/1541224 – joym8 Nov 16 '18 at 19:53

0 Answers0