To perform an HTTP request using cURL (a command-line tool for transferring data with URLs), you can use the following syntax:
curl [options] [URL]
Here's a basic example of making an HTTP GET request to a URL:
css
curl https://example.com
This will send a GET request to https://example.com
and print the response body to the terminal.
You can also specify additional options to customize the request. For example, to include headers or send data in the request body:
css
curl -X POST -H "Content-Type: application/json" -d '{"key": "value"}' https://example.com
This command sends a POST request with a JSON payload to https://example.com
.
Here are some common options you might use with cURL:
-X
: Specify the HTTP method (GET, POST, PUT, DELETE, etc.).-H
: Include headers in the request.-d
: Send data in the request body (for POST requests).-i
: Include the response headers in the output.-v
: Enable verbose mode to see more details about the request and response.
You can find more options and detailed information in the cURL documentation or by running curl --help
in your terminal.