C#C
C#5mo ago
TDRR

400 bad request on seemingly valid POST

I'm guessing this is a really stupid thing I missed or something like that, but I'm not sure what exactly it is.
I have this post handler:
// added with app.MapPost("/usernew", UserPost);
public static void UserPost (string email, string userName, string password)
{
    using (var ctx = new EventtuallyContext())
    {
        var hasher = new PasswordHasher<User>();

        ctx.Add(new User {
            UserName = userName,
            Email = email,
            PasswordHash = hasher.HashPassword(null!, password),
            RegistrationDate = DateTime.Now
        });

        ctx.SaveChanges();
    }
}

Testing with curl:
$ curl -v -d '{"email": "asd@test.com", "userName": "testname", "password": "mypassword"}' -H 'Content-Type: application/json' http://localhost:5000/usernew
* Host localhost:5000 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying [::1]:5000...
* Connected to localhost (::1) port 5000
* using HTTP/1.x
> POST /usernew HTTP/1.1
> Host: localhost:5000
> User-Agent: curl/8.14.1
> Accept: */*
> Content-Type: application/json
> Content-Length: 75
> 
* upload completely sent off: 75 bytes
< HTTP/1.1 400 Bad Request
< Content-Length: 0
< Date: Wed, 20 Aug 2025 15:58:23 GMT
< Server: Kestrel
< 
* Connection #0 to host localhost left intact
Was this page helpful?