How do I send HTTP DELETE request? [C#/.NET Code]

An example of sending an HTTP DELETE request to the server. The Accept: */* request header tells the server that the client can accept any type of media in the server's response. In this HTTP DELETE request example, we are sending a DELETE request to the ReqBin echo URL. The Content-Type server response header indicates the MIME type of the returned data. The C#/.NET code was automatically generated for the DELETE Request example.
How do I send HTTP DELETE request? [C#/.NET Code] Send
DELETE /sample/delete/json HTTP/1.1
Host: reqbin.com
Accept: */*
Authorization: Bearer mt0dgHmLJMVQhvjpNXDyA83vA_PxH23Y

Updated: Viewed: 28003 times
C#/.NET code for DELETE Request example

C#/.NET code for DELETE Request Example

This C#/.NET code snippet was generated automatically for the DELETE Request example.
<< Back to the DELETE Request example

What is HTTP?

HTTP (Hypertext Transfer Protocol) is a network communication protocol widely used to transfer data between an HTTP client (browser or mobile application) and the server. The HTTP protocol assumes the use of a client-server architecture for data transfer. The client application sends the request to the server, and the server processes the client's request and sends a response back to the client. Some server responses may contain data in the body of the server response (for example, an HTML page), and some may only have headers and an empty body. Each HTTP message consists of a request string, HTTP headers, and a message body.

What is the HTTP DELETE request method?

The HTTP DELETE request is used to delete a resource from the server. The HTTP DELETE method should not contain a body, as sending a body in a DELETE request may cause some servers to reject it. The DELETE method is defined as idempotent, which means that multiple, identical DELETE requests should have the same impact on the server as a single request.

HTTP DELETE Request Example
DELETE /path HTTP/1.1
Host: server.com

What are the common HTTP DELETE response codes?

HTTP response status codes indicate the status of a completed request. When the server has successfully processed a DELETE request, it can respond with several response status codes:

  • 200 (OK) - the action completed successfully. The server response may have a message body.
  • 204 (No Content) - the action completed successfully. The server response does not have a message body.
  • 202 (Accepted) - the action is likely to be successful but not yet complete.

HTTP DELETE Request Example

An example of sending an HTTP DELETE request to a ReqBin echo URL.

DELETE Request Example
DELETE /echo/delete/json HTTP/1.1
Authorization: Bearer {token}
Host: reqbin.com
Accept: */*

The server's response to our HTTP DELETE request.

HTTP DELETE Response Example
HTTP/1.1 204 OK
Content-Length: 0

See also

Generate code snippets for C#/.NET and other programming languages

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