{"id":6486,"date":"2020-11-03T17:45:51","date_gmt":"2020-11-03T12:15:51","guid":{"rendered":"https:\/\/www.h2kinfosys.com\/blog\/?p=6486"},"modified":"2026-01-02T05:15:09","modified_gmt":"2026-01-02T10:15:09","slug":"http-request-methods-delete-patch","status":"publish","type":"post","link":"https:\/\/www.h2kinfosys.com\/blog\/http-request-methods-delete-patch\/","title":{"rendered":"HTTP Request Methods: DELETE, PATCH"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\"><strong>DELETE<\/strong> method:<\/h2>\n\n\n\n<p>This <a href=\"https:\/\/www.h2kinfosys.com\/blog\/http-request-methods-delete-patch\/\">HTTP Request methods<\/a> is used to delete a resource which is present in the server. Sending the message body on a delete request will have because servers reject the request. But the data can be sent by using URL parameters to server. The delete method is called <a href=\"https:\/\/en.wikipedia.org\/wiki\/Idempotence\" rel=\"nofollow noopener\" target=\"_blank\">idempotent<\/a>, that is if multiple delete requests can have the same effect on a single request.&nbsp;<\/p>\n\n\n\n<p>Consider an example for sending a delete request to the server.<\/p>\n\n\n\n<p>The result is shown as<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/GbRYFZwfG3bABMEjRERrxpww-Jj2tN0duvnS2JSpgPRBXeJvF2kz-1-8q43ruYkavJS31i_kxFoImEh5YGTj53NxyEdQj5IyhpAGIU5bbgzmpTIzq6BoF9FnknENP_mlYLh2H-N18Rj3WaPfEQ\" alt=\"HTTP Request Methods\" title=\"\"><\/figure>\n\n\n\n<p>The server response is:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/Uf0HU0PeypD3oOgSUqGNd5AQUSnDtA0uxqIZUeKPOgKktSYp1xq8ccM0ruHhJkRFFN8oxCmX0L4IONL3kMgjFnsmeuXkzb6IohNyvPsbqjjc6cdfBtNzfAZHEyI6uWtL_hXtqdbm0DOI_13qFg\" alt=\"HTTP Request Methods\" title=\"\"><\/figure>\n\n\n\n<p><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/zlUyvRfPzBIoYAPAYAer-jwaCoL-tbGwjj3tFb7QAJOpsiA7ktKNMj75u-fPpRo8QYkBYXuveNQ85-k700_OJUo0iTIotMKhtn-CiOy13-xhoBJTxxVQv8Mls8ph8Xk4BT68nKzsNuJeiehY4A\" width=\"1070.5528353452682\" height=\"351.0667061805725\" alt=\"\" title=\"\"><\/p>\n\n\n\n<p>The sample example with respect to the database for delete request is<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;?php\n$servername =&nbsp;\"localhost\";\n$username =&nbsp;\"username\";\n$password =&nbsp;\"password\";\n$dbname =&nbsp;\"myDB\";\n\n\/\/ Create connection\n$conn =&nbsp;new&nbsp;mysqli($servername, $username, $password, $dbname);\n\/\/ Check connection\nif&nbsp;($conn-&gt;connect_error)&nbsp;{\n&nbsp;&nbsp;die(\"Connection failed: \"&nbsp;. $conn-&gt;connect_error);\n}\n\n\/\/ sql to delete a record\n$sql =&nbsp;\"DELETE FROM My Guests WHERE id=3\";\n\nif&nbsp;($conn-&gt;query($sql) === TRUE) {\n&nbsp;&nbsp;echo&nbsp;\"Record deleted successfully\";\n}&nbsp;else&nbsp;{\n&nbsp;&nbsp;echo&nbsp;\"Error deleting record: \"&nbsp;. $conn-&gt;error;\n}\n\n$conn-&gt;close();\n?&gt;<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>PATCH<\/strong> Method:<\/h2>\n\n\n\n<p>A PATCH is considered as analogous to the update. A patch request will be considered a group of instructions on how to modify a resource. A patch need not be idempotent that is always any number need not be repeated. Identical requests will leave the resource in the same state. PATCH like PUT has some side-effects on other resources.&nbsp;<\/p>\n\n\n\n<p>Consider an example of patch request<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/FXp-xPeGEpwKXzaFjYWmfR2rczWfNtSf3HC2JzV5e9cRSbCyNx5Uy7CZ3K76fT2aaM11m_R9u0KHmLU5MasieUHq9ma_-b54mNVBL30sYyLuUYo_vFGj2967qPznEiBFU8hxvYCzQmZqDS0roQ\" alt=\"HTTP Request Methods\" title=\"\"><\/figure>\n\n\n\n<p><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/WoGdn57b7T-ovKyhgkWH9KmTqEMOzYaUqaWp6feTQRf3C7GtJKJ8PTUUJTjUzB77wknPdDxduuJndNo-LBn9JBw-qPEzUNlXIt071xfOSs77wjSujT0Z63EbUH8Iz1XnIWKVSA0exTDYt2AWgA\" width=\"1061.3965039253235\" height=\"246.61534070968628\" alt=\"\" title=\"\"><\/p>\n\n\n\n<p>A response will be indicated by any 2XX status code. An example of 204 response is considered as<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/uyRVqUE8lAKnBiubQwvOF6ui7ux9lymPMGfv4ng0EAZG8ic3x4STR3DbHkOz6awXGutRIqyWCDwrhqEDi8X14CEB5xKM972ByVjopxDplVzywFQ4wz9q-lb13CEFYDmdqVoOVlE7g7KVy04YWg\" alt=\"HTTP Request Methods\" title=\"\"><\/figure>\n\n\n\n<p><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/uyRVqUE8lAKnBiubQwvOF6ui7ux9lymPMGfv4ng0EAZG8ic3x4STR3DbHkOz6awXGutRIqyWCDwrhqEDi8X14CEB5xKM972ByVjopxDplVzywFQ4wz9q-lb13CEFYDmdqVoOVlE7g7KVy04YWg\" width=\"974\" height=\"253.68353462219238\" alt=\"\" title=\"\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>HTTP DELETE and PATCH are powerful tools when used with precision. DELETE ensures proper resource cleanup, while PATCH enables efficient and safe partial updates. Understanding their behavior, limitations, and best practices is critical for building scalable, secure, and modern APIs. When designed correctly, these methods help developers create systems that are robust, predictable, and easy to evolve.<\/p>\n\n\n\n<p>By applying DELETE and PATCH thoughtfully, teams can maintain clean data models, reduce errors, and build APIs that align with real-world application needs.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>DELETE method: This HTTP Request methods is used to delete a resource which is present in the server. Sending the message body on a delete request will have because servers reject the request. But the data can be sent by using URL parameters to server. The delete method is called idempotent, that is if multiple [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":6714,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-6486","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-qa-tutorials"],"_links":{"self":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/posts\/6486","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/comments?post=6486"}],"version-history":[{"count":1,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/posts\/6486\/revisions"}],"predecessor-version":[{"id":33754,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/posts\/6486\/revisions\/33754"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/media\/6714"}],"wp:attachment":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/media?parent=6486"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/categories?post=6486"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/tags?post=6486"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}