How to Use curl to Send JSON Data in a POST Request?

22 Replies, 1326 Views

Nice one! Just a heads-up, if you’re using double quotes in your JSON, make sure to escape them properly in the terminal. I’ve had curl send json fail because of unescaped quotes.

For example:
```bash
curl -X POST -H "Content-Type: application/json" -d '{\"key\":\"value\"}' https://example.com/api
```

Also, `json_pp` is a neat Perl tool for pretty-printing JSON if you don’t have `jq` installed.

Messages In This Thread



Users browsing this thread: 1 Guest(s)