How to send a DELETE request with cURL - TechvBlogs

How to send a DELETE request with cURL

In this article, we’re going to explain how to use cURL to make DELETE requests. The HTTP DELETE method is used to delete data from the remote server.

Suresh Ramani - Author - TechvBlogs
Suresh Ramani

1 year ago

TechvBlogs - Google News

What is cURL?

Curl is a command-line utility that allows users to create network requests. Curl is accessible on Windows, Linux, and Mac, making it the go-to choice for developers across all platforms.

A cURL is computer software and command-line tool used to make requests for different protocols. But the most popular usage with the curl command is making HTTP delete requests. Even the curl command-line tool is created for the Linux operating systems it is cross-platform and can be used for Windows, MacOSX, BSD, etc. In this tutorial, we will learn how to make different HTTP DELETE requests by using curl.

In this article, we’re going to explain how to use cURL to make DELETE requests. The HTTP DELETE method is used to delete data from the remote server.

Read Also: How to Install and Use Curl on Ubuntu 22.04


The most basic command you can execute with cURL is an HTTP DELETE request without a payload.

To tell cURL to use a DELETE request method we can use the -X--request command-line option, the following command will perform the request using the DELETE verb and output the response body:

curl -X DELETE

The -X flag specifies a custom request method to use when communicating with the HTTP server. By default, the GET method is used unless some other method is specified.

HTTP DELETE request with data

Sending a payload body with a DELETE request is something discouraged and not recommended.

The only reason we didn't forbid sending a body is because that would lead to lazy implementations assuming no body would be sent.

However, it's not strictly forbidden in RFC 7231, and you might be in the need to test it from a client perspective.

A payload within a DELETE request message has no defined semantics; sending a payload body on a DELETE request might cause some existing implementations to reject the request.

If despite the warning, you need to send some data in the payload of the DELETE request, you can use the -d--data command-line option. When using the data option, cURL sends data just like your browser would when you fill an HTML form and press the submit button. In addition, cURL will automatically add the Content-Type header with an application/x-www-form-urlencoded value.

curl -X DELETE -d "field=value&tool=curl"

Thank you for reading this article.

Read Also: How to make a POST request with cURL

If you want to manage your VPS / VM Server without touching the command line go and  Checkout this linkServerAvatar allows you to quickly set up WordPress or Custom PHP websites on VPS / VM in a  matter of minutes.  You can host multiple websites on a single VPS / VM, configure SSL certificates, and monitor the health of your server without ever touching the command line interface.

If you have any queries or doubts about this topic please feel free to contact us. We will try to reach you.

Comments (0)


Note: All Input Fields are required.