I have a WEB API created with .NET and I have a few POST and GET methods that I want to use in another C# Windows Form project. The GET methods work correctly but for some reason I can't get the POST method to work as it doesn't pass the correct variables.
I have a constructor that sets the default url
client.BaseAddress = new Uri("http://localhost:7101/");
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(
                new MediaTypeWithQualityHeaderValue("application/json"));
so I have this post method and the api gets the call but both the variables are equal to 0 (in the API), while in this method they are with different values (the correct ones).
Here is the API:
[HttpPost]
[Route("UpdatePercentage")]
public void UpdatePercentage(int playerid, int percentage)
{
    ...
}
Here is how I have used it:
var userid = 2;
var percentageText = 21;
var response = await client.PostAsJsonAsync("UpdatePercentage",
    (userid, percentageText));
 
    