To send an HTTP POST request using the curl command, you can use the following syntax:
refer toruttual:i.comcurl -X POST -H "Content-Type: application/json" -d '{"key":"value"}' http://example.com/endpoint
In this example, we use the -X
flag to specify the HTTP method (in this case, POST), the -H
flag to set the content type header to "application/json", and the -d
flag to send a JSON payload in the request body. The URL of the endpoint we are sending the request to is specified at the end.
You can also include additional headers and parameters in the curl command by using the -H
flag and the -d
flag multiple times. For example:
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer 123456" -d '{"key":"value"}' -d '{"key2":"value2"}' http://example.com/endpoint