You can use curl
command to send a DELETE request to a specific URL. The -X
option allows you to specify a custom request method to use when communicating with the HTTP server.
Here is a basic example:
curl -X DELETE http://example.com/resource/1
In the above command, -X DELETE
tells curl
to send a DELETE request. http://example.com/resource/1
is the URL of the resource you want to delete.
You can also include headers in your curl
command using the -H
option. For example, if you need to include an authentication token, you could do:
curl -X DELETE -H "Authorization: Bearer your_token" http://example.com/resource/1
In this command, -H "Authorization: Bearer your_token"
adds an Authorization header with a Bearer token.
If you need to pass data to the server, you can use the -d
or --data
option. For example:
curl -X DELETE -d "param1=value1¶m2=value2" http://example.com/resource/1
In this command, -d "param1=value1¶m2=value2"
sends the provided data in the request body.
Please note that not all servers support DELETE requests, and even those that do may not support sending data in the body of a DELETE request. Always check the API documentation to make sure you're formatting your requests correctly.