How do I properly make a POST in cURL? Need help with the syntax! or What’s the correct way to send a

18 Replies, 1446 Views

Bro, I feel you. Had the same issue last week.

Your command looks mostly right, but some APIs freak out if you don’t escape the JSON properly. Try:

```
curl -X POST https://example.com/api -d "{\"key\":\"value\"}"
```

Or use `@file.json` if the payload is big.

Also, yeah, `-H "Content-Type: application/json"` is pretty much mandatory for JSON post in curl.

Messages In This Thread



Users browsing this thread: 1 Guest(s)