I have an ASP .NET 6 Rest service in which I have a pretty basic Refit API interface defined for a GET operation with a request object that has several properties on it. Here's the request definition:
[Get("/users")]
Task<Auth0GetUsersResponse> GetUsers(Auth0GetUsersRequest request, [Header("Authorization")] string bearerToken);
The problem is that when Refit serializes the request object and constructs the URL parameters, it generates Boolean values with capital first letters, e.g. True or False. Unfortunately, URLs are case-sensitive and these values are not valid for Boolean inputs, so the API I am calling returns a 400. Here's the GET that is being generated:
GET /api/v2/users?include_totals=True
That value "True" is where I'm dying. Here's the property definition on the Auth0GetUsersRequest object:
public bool include_totals { get; set; }
And here's how I am registering the service in Startup.cs:
services.AddRefitClient<IAuth0ManagementApi>();
This is all really basic stuff. I'm not doing any extra configuring of any kind that I know of.
I've spent most of today trying to figure out ways to make that be "true" instead of "True", switching between System.Text.Json and Newtonsoft frameworks, changing property case convention in the client settings (which shouldn't have any impact but I was grasping at straws), even using a custom JsonConverter. Nothing affects it - Refit just insists on making bool values start with uppercase letters!
This only seems to be happening when serializing URL bool parameters in a GET. When serializing a POST body it works as expected, with properly lowercase values for bools.