I have a url (that I can't really modify) that has id as part of the route and then a start date and end date as query parameters.
I'm not sure how to mix route parameters and query parameters and bind them.
https://localhost:7285/api/roomEvents/1a?start=2022-10-30T00%3A00%3A00-04%3A00&end=2022-12-11T00%3A00%3A00-05%3A00
I'm struggling to bind the id, start, and end strings in my c# web api controller.
I've tried
public class RoomEvents : BaseApiController
{
[AllowAnonymous]
[HttpGet("{id}?start={start}&end={end}")]
public async Task<ActionResult> GetRoomEvents(string id, string start, string end)
{
return HandleResult(await Mediator.Send(new EventsByRoom.Query { Id = id, Start = start, End = end }));
}
}
but I get
System.ArgumentException HResult=0x80070057 Message=The literal section '?start=' is invalid. Literal sections cannot contain the '?' character. (Parameter 'routeTemplate')
Source=Microsoft.AspNetCore.Routing
[HttpGet("{id}")]. This can then be called with/api/roomEvents/1a?start=...&end=...