I have an ASP.NET Core 3.1 Web API project. There is an enum with the following details:
public enum TestPageType
{
Item1,
Item2,
Item3,
Item4
}
[HttpGet("{type}/{mode}")]
[ProducesResponseType(400)]
[ProducesResponseType(500)]
public IEnumerable<ControlInfo> GetControlData(TestPageType type, string mode)
{
switch (type)
{
case TestPageType.Item1:
case TestPageType.Item2:
case TestPageType.Item3:
case TestPageType.Item4:
default:
return _testService.GetData(GetControlType(type), 0, readonlyMode);
}
}
From the client application, Item5 is sent as input to the API endpoint:
https://localhost:8080/api/test/GetControlData/item5/edit
In this on debugging I see that first item from the TestPageType enum : Item1 is picked.
Can anyone help me to resolve this issue?
https://localhost:8080/api/test/GetControlData/Item5/edit(Item5 with a capital I) - the parameter values might be case-sensitive ....Item5doesn't exist in your enum, and since an enum is a value type, it will probably default to0orItem1. You could try withTestPageType? typeas the parameter perhaps?