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

14 Replies, 1619 Views

Windows cmd hates JSON quotes. Try this monstrosity:

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

Or, honestly? Use `curl --data @file.json` and save the JSON to a file. Less headache.

For debugging, `curl -i` shows headers in the response—might clue you in on what’s wrong.

Messages In This Thread



Users browsing this thread: 1 Guest(s)