How to properly use curl for sending JSON data? or Having trouble with curl sending JSON? Any tips?[

14 Replies, 1007 Views

Double-check your JSON! Even a missing comma or extra bracket can break it.

For curl sending json, I’d recommend:

```bash
curl -X POST http://example.com/api -H "Content-Type: application/json" -d "$(jq -c . < data.json)"
```

This uses `jq` to minify and escape the JSON properly. Works like a charm for me.

Messages In This Thread



Users browsing this thread: 1 Guest(s)