cURL Debugging, Performance, and Scripting/Send request body from a file

Post the contents of a local file as the request body.

Section: Config Files and Scripting

Send request body from a file

bash
bash
curl -X POST -H 'Content-Type: application/json' --data @payload.json https://api.example.com/items
Explanation

Prefix a filename with `@` for `--data` to read from file.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Config Files and Scripting
Use a curl config file
Load options from a config file.
OpenIn sheetbashsame section
Example curl config file
Store headers, auth, and URL in a reusable config file.
OpenIn sheetinisame section
Use --json shortcut
Send JSON body with curl's JSON convenience option.
OpenIn sheetbashsame section
Use output variables
Name outputs using transfer variables.
OpenIn sheetbashsame section
Script-safe status check
Capture HTTP status for shell scripts.
OpenIn sheetbashsame section
Parse JSON with jq
Pipe JSON output to jq for filtering.
OpenIn sheetbashsame section