How to properly use curl POST JSON in my API requests? or What's the correct syntax for a curl POST J

14 Replies, 1618 Views

Not all APIs are the same, but 99% of the time, curl post json needs `Content-Type: application/json`. Some APIs also freak out if you don’t include `-X POST` (even though `-d` implies POST).

Try:
```bash
curl https://api.example.com/data -H "Content-Type: application/json" -d '{"name":"test","value":123}'
```

If it’s still broken, the API might want nested JSON or different fields. Check their docs or post the error here.

Messages In This Thread



Users browsing this thread: 1 Guest(s)