How do I properly use curl --post to send data in a request? or What's the correct syntax for curl --

19 Replies, 2357 Views

Ah, the classic curl confusion! `curl --post` isn’t valid—use `-X POST` or just `-d`.

For form data:
`curl -d "name=foo&age=25" https://example.com`

For JSON, don’t forget the header:
`curl -X POST -H "Content-Type: application/json" -d '{"name":"foo"}' https://example.com`

Also, try https://reqbin.com/ to test requests before curling.

Messages In This Thread



Users browsing this thread: 1 Guest(s)