Read the request body from a file
Send a request body from a file with curl -d @file. The option strips newlines from the file, so use --data-binary @file when the exact bytes matter.
A request body lives in a file and you want curl to send it, and the byte count the server receives is not the one you expected.
printf 'line one\nline two\n' > body.txt
wc -c < body.txt
curl -s -d @body.txt http://127.0.0.1:8000/
curl -s --data-binary @body.txt http://127.0.0.1:8000/18
received 16 bytes
received 18 bytesWith @ the argument is a file name, and -d posts its contents as application/x-www-form-urlencoded. The curl manual notes that -d removes carriage returns and newlines from the file, which is why 18 bytes became 16 on the wire. --data-binary sends the file as it is, and it is the right choice for JSON with a trailing newline or any multi-line body.
Neither option sets a content type for you beyond the form default, so add -H 'Content-Type: application/json' for a JSON file. A very large body makes curl send an Expect header and wait for the server to agree, which -H 'Expect:' turns off.