curl --json '{"name":"test"}' https://api.example.com/items

Category: Web App Development

curl --json '{"name":"test"}' https://api.example.com/items

POST a JSON body with curl's --json shortcut

Sends a POST request with the given object as the JSON body and sets Content-Type to application/json automatically. The --json flag is a shorthand for --data with that header, available in curl 7.82 and newer. Add -i to inspect the response headers too.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.