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

19 Replies, 2366 Views

curl --post? Nah, fam. It’s `-d` for data.

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

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

`-X POST` is redundant with `-d`, but some folks like being explicit.

Messages In This Thread



Users browsing this thread: 1 Guest(s)