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

22 Replies, 1763 Views

Man, I feel you on the silent fails. One thing that helped me was using the `-v` flag for verbose output. It shows the full request and response, so you can see exactly where things go wrong.

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

Also, if you’re on macOS, `pbpaste` can be a lifesaver for pasting JSON directly into the terminal.

Messages In This Thread



Users browsing this thread: 1 Guest(s)