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

19 Replies, 2362 Views

The correct syntax for form data with curl is:
`curl -X POST -d "name=foo&age=25" https://example.com`

For JSON:
`curl -X POST -H "Content-Type: application/json" -d '{"name":"foo","age":25}' https://example.com`

`-X POST` is just explicit, while `-d` defaults to POST. No such thing as curl --post, tho.

Messages In This Thread



Users browsing this thread: 1 Guest(s)