How to Properly Send POST Data with curl? Need Help! or What’s the Best Way to Use curl POST Data in

16 Replies, 1886 Views

For curl post data, the Content-Type header is *everything*. If you don’t specify it, the server might just ignore your payload.

Here’s a working example for JSON:
```
curl -X POST https://example.com/api \
-H "Content-Type: application/json" \
-d '{"key":"value"}'
```

And for form data, use:
```
curl -X POST https://example.com/api \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "key=value"
```

The server’s docs should tell you which one it expects.

Messages In This Thread



Users browsing this thread: 1 Guest(s)