Sending DELETE Request with Body [Node.js Code]

HTTP DELETE requests, like GET and HEAD requests, should not contain a body, as this may cause some servers to work incorrectly. But you can still send data to the server with an HTTP DELETE request using URL parameters. RFC 2616 does not explicitly prohibit or encourage sending a body with an HTTP DELETE request, but most servers ignore it. In this HTTP DELETE Body example, we send an HTTP DELETE request to the ReqBin echo URL. Click Send to execute the HTTP DELETE Body example online and see the results. The Node.js code was automatically generated for the HTTP DELETE Body example.
Sending DELETE Request with Body [Node.js Code] Send
DELETE /echo/delete/json HTTP/1.1
Host: reqbin.com

Updated: Viewed: 20826 times
Node.js code for HTTP DELETE Body example

Node.js code for HTTP DELETE Body Example

This Node.js code snippet was generated automatically for the HTTP DELETE Body example.
<< Back to the HTTP DELETE Body example

What is HTTP?

HTTP (The Hypertext Transfer Protocol) is the core of the WWW (World Wide Web) and powers websites and mobile applications. An HTTP connection is used to transfer information between networked devices and to facilitate client-server communication. HTTP works as a request-response protocol between the client and server. All modern programming languages natively support HTTP.

What is HTTP DELETE?

The DELETE method is one of the nine standard HTTP (Hypertext Transfer Protocol) request methods for deleting resources from the server. By using the HTTP DELETE request method, we ask the server to delete the specified resource. The DELETE is an idempotent method. The DELETE method, like the GET method, can not have a request body. Unlike GET and HEAD requests, DELETE requests can change the server's state.

HTTP DELETE Body Example

The following is an example of sending an HTTP DELETE Body request to a ReqBin echo URL:

HTTP DELETE Body Sample
DELETE /echo/delete/json HTTP/1.1
Host: reqbin.com

The server's response to our HTTP DELETE Body request:

HTTP DELETE Response Example
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 19

{"success":"true"}

See also

Generate code snippets for Node.js and other programming languages

Convert your HTTP DELETE Body request to the PHP, JavaScript/AJAX, Node.js, Curl/Bash, Python, Java, C#/.NET code snippets using the Node.js code generator.