Need a simple curl post example – how do I send data with curl? or Can someone share a basic curl pos

18 Replies, 1830 Views

Not bad! Your curl post example for JSON is correct. For form data, it’s a bit trickier.

If it’s simple key-value pairs (no files), use `-d` with the URL-encoded header:
```bash
curl -X POST https://example.com/api -d "param1=value1" -H "Content-Type: application/x-www-form-urlencoded"
```

For files or multipart, `-F` is your friend:
```bash
curl -X POST https://example.com/upload -F "name=test" -F "doc=@document.pdf"
```

Try https://reqbin.com/ to test these online.

Messages In This Thread



Users browsing this thread: 1 Guest(s)