HTTP/1.1 415 Unsupported Media Type from an ASP.NET Core POST endpoint that takes a JSON body means the request did not say it was JSON. The body can be perfectly valid; send the header Content-Type: application/json with it and the same request succeeds.

With curl that is -H "Content-Type: application/json" next to -d. In the test below that one header turned the 415 into a 200 with the object echoed back.

The error

curl.exe -s -D - -d "@body.json" http://127.0.0.1:15704/patients
HTTP/1.1 415 Unsupported Media Type
Content-Length: 0
Date: Fri, 06 Nov 2026 07:49:52 GMT
Server: Kestrel

That is the whole response: no body, no problem details. The server's console log had no line for this request either, so there was nothing on either side that named the missing header.

Why it happens

The endpoint binds its parameter from a JSON body:

app.MapPost("/patients", (Patient p) => Results.Ok(p));
...
record Patient(string Name, string Email);

-d makes curl send a POST, and when no type is given curl labels the body as a form. Running the same request with -v showed the header it actually sent:

curl.exe -s -v -o NUL -d "@body.json" http://127.0.0.1:15714/patients 2>&1 | Select-String '^[<>]'

> POST /patients HTTP/1.1
> Host: 127.0.0.1:15714
> User-Agent: curl/8.21.0
> Accept: */*
> Content-Length: 52
> Content-Type: application/x-www-form-urlencoded
...
< HTTP/1.1 415 Unsupported Media Type
...

The minimal API endpoint expected JSON for the Patient parameter, saw application/x-www-form-urlencoded, and answered 415. The body file held valid JSON; the only difference in the request that succeeded was the header.

Compare the two responses. The refused one had Content-Length: 0 and no Content-Type at all. The accepted one came back with Content-Type: application/json; charset=utf-8 and the patient object, which is what the handler returns. The handler's result appeared only in the second response.

The fix

curl.exe -s -D - -H "Content-Type: application/json" -d "@body.json" http://127.0.0.1:15704/patients
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Date: Fri, 06 Nov 2026 07:50:06 GMT
Server: Kestrel
Transfer-Encoding: chunked

{"name":"Maria Garcia","email":"maria@example.test"}

The body file was written in Windows PowerShell 5.1 with '{"name":"Maria Garcia","email":"maria@example.test"}' | Out-File body.json -Encoding ascii and sent from that file with -d "@body.json". In your own client code, set the request's content type to application/json in the same way. In this test the server side needed no change: the same endpoint, the same body, one extra header.

How it was reproduced

A dotnet new web project (net10.0) with the endpoint above, started on http://127.0.0.1:15704 (a second run for the -v capture on 15714) and called with the Windows built-in curl 8.21.0. .NET SDK 10.0.403, Microsoft.AspNetCore.App 10.0.14, Windows 11. The body was 52 bytes of JSON with two fictional fields. Only a minimal API endpoint was tested; a controller action was not part of this run.

Frequently asked

Why does my ASP.NET Core POST return 415 Unsupported Media Type?
The request did not carry Content-Type: application/json. In the test curl -d labelled the body application/x-www-form-urlencoded, and the minimal API endpoint that binds a JSON body answered 415.
How do I send JSON with curl to an ASP.NET Core API?
Add -H "Content-Type: application/json" next to -d. On Windows PowerShell 5.1, put the JSON in a file and send it with -d "@body.json".
Does the 415 response say what is wrong?
Not here. It had Content-Length: 0 and the server logged nothing for it. Run curl with -v to see the Content-Type header that was actually sent.

More decoded errors in the Fixes category.