This project I've inherited is a bit of a botch job; it's a Windows Service with an api layer tacked onto it... I don't think this is the issue though
Example controller
[Route("Test/GetUsers")]
[HttpGet]
public string GetUsers(bool? enabled=null, bool? sync=null)
{
// do whatever
}
So calling https://myapi/Test/GetUsers?enabled=true&sync=true
would work just fine
However, if I call https://myapi/Test/GetUsers?enabled=true
I get 400 Bad Request: "Arguments cannot be null" back from the server
After fiddling around a bit, I found
[Route("Test/GetUsers")]
[HttpGet]
public string GetUsers(bool enabled=false, bool sync=false)
{
// do whatever
}
would mean https://myapi/Test/GetUsers?enabled=true
would work fine.
I actually want the null bool though, because the logic works like this
if (enabled != null)
{
// add Enabled = True/False clause to the query
}
So if enabled
were null, it's going to get both enable and disabled users