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

19 Replies, 2359 Views

Hey! You’re close, but curl --post isn’t the correct flag—it’s actually `-d` or `--data` for form data. Try this:
`curl -d "name=foo&age=25" https://example.com`

For JSON, use `-H "Content-Type: application/json"` and `-d '{"name":"foo","age":25}'`.

And `-X POST` explicitly sets the method, while `-d` implies POST. Hope that helps!

Messages In This Thread



Users browsing this thread: 1 Guest(s)