{"id":6484,"date":"2020-11-03T17:39:34","date_gmt":"2020-11-03T12:09:34","guid":{"rendered":"https:\/\/www.h2kinfosys.com\/blog\/?p=6484"},"modified":"2020-11-05T18:36:08","modified_gmt":"2020-11-05T13:06:08","slug":"http-request-methods-get-post-put","status":"publish","type":"post","link":"https:\/\/www.h2kinfosys.com\/blog\/http-request-methods-get-post-put\/","title":{"rendered":"HTTP Request Methods: GET, POST, PUT"},"content":{"rendered":"\n<p>HTTP: is the <a href=\"https:\/\/www.h2kinfosys.com\/blog\/http-request-methods-get-post-put\/\">Hypertext Transfer Protocol<\/a>(HTTP) enables the communication between client and server. It has a request-response protocol for communication. The request sent by the client is responded by the server.<\/p>\n\n\n\n<p>The HTTP methods used are:&nbsp;<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>GET<\/li><li>POST<\/li><li>PUT<\/li><li>HEAD<\/li><li>DELETE<\/li><li>PATCH<\/li><li>OPTIONS<\/li><\/ul>\n\n\n\n<p>The set of commands are as follows:<\/p>\n\n\n\n<p>This article explains : GET, POST &amp; PUT methods.<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li><strong>GET<\/strong>: This command is mainly used to get data from the resource. This command sends data as a part of the URL, it appends the form data into the URL in the name\/value pairs. The length of the URL is limited to 2048 characters. We should not use GET method if password or any sensitive information is there in the server. Mainly useful for form submission where the user want to bookmark the result. Get is better for non-secure data like query things in Google. GET can\u2019t be used to send binary data like images etc.<\/li><\/ol>\n\n\n\n<p>The syntax is&nbsp;<\/p>\n\n\n\n<p>&lt;form action=\u201dsome.php\u201d method=\u201dGET\u201d&gt;<\/p>\n\n\n\n<p>For example consider a simple example accepting name and password<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/48d0AI6c_GymU_D3z85LM1LSCogxMyyr6abtRuonLCBXuhbpnuFcOntbuc00AaZui9rFaqC6Q_5Qt07L4PxfI3yuQMr-I4m97uXRZpIFhwMzi9wnNPx48isH16JUFAXbnIPP9E50s96uj-HnSw\" alt=\"Http Methods Get Post Put\" title=\"\"><\/figure>\n\n\n\n<p><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/F1-HBDmGR81W6HvNtkP7sVATFAIMxO-2KJLrrUEqFozEoXN5vH2tTZdbmLAeIt5us11XO2Px2iGp-JkiCTJDgWoKhKg5xWAwFvSviy0t2yPg1_azl8TRDkmpuazNaHkUzaFWh1zEiJNXvhuLBg\" width=\"1088.495061635971\" height=\"258.98785281181335\" alt=\"\" title=\"\"><\/p>\n\n\n\n<p>2. <strong>POST<\/strong> method:<\/p>\n\n\n\n<p>POST is used to send the information from the server or to the server. Let us see one example of passing information through post method.<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Create a notepad file to write a simple program using html .<\/li><li>Use method post and input type name and company name text fields and a submit button.<\/li><li>Save the file.<\/li><li>Run the file.<\/li><\/ol>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/q7BZW-4rjXFCg1S1cIkBc0X4zyxPO49yEbBl8uXJvfIZ8Uv5kPi3uvsQ9Cr0592DvW3ij8g8nMISEEVq8S3Av7gZ1qitv3kVMToCXChaUqmYWNj3wXBkXHb4lZuA-l1yALTQTCMVrmGjvpx6GQ\" alt=\"\" title=\"\"><\/figure>\n\n\n\n<p><br>The design of the form looks as above where the name and company fields has to be passed to a file called post.php.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/3GDSc2yyjuJweo8M803qw-YJB0xThCd-om6C9fpVnhzQTB9c8muXQxtqq8Y4MQJFzWS8d5nJdDvR0OBbVkmTnCmV1tZ-Tz_Z_KrMnWV6S4Dxq6I_o-kFHoj-Lh-ayQ5Uot1aE5bepZC3XJ4GtA\" alt=\"\" title=\"\"><\/figure>\n\n\n\n<p>And run the file and the post method passes the information without showing it in the URL and gets the result.<\/p>\n\n\n\n<p><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/Mc2nDgt0fOOOf_mvQltCCIVa10gEjc_C_h5muKWqLCvriQJFOARJKj0Z4-SKBXzs7wGM-g64tw8HxHZU2MsK3WnGr7AoAo67ePGXoK5TgXjkMmk0cVk7gcJ85KBTQcJbsM4KPFDezTxUyhY1Zg\" width=\"1042.6540489196777\" height=\"364.90467977523804\" alt=\"\" title=\"\"><\/p>\n\n\n\n<p><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/LDodX6k4JU4LNzXh1RUwujEif7xf1jd2G3MhOetQi-YH1wyIFt42eU45BVD1EnO11r7oqop2vj7CjqMVifvUSkOaJsqNhrv1EgKKgM1BJRLQO2c26r0dEyxY_e4ShNLdwEkCXhNzO_s3YWI-SQ\" width=\"1042\" height=\"304.16324615478516\" alt=\"\" title=\"\"><\/p>\n\n\n\n<p>The main difference between get and post method the get method displays the information passed in the URL where as post method hides the information in the URL.there are various advantages in this post method , there is no restrictions for the data size to be sent.we can sent binary data and uses the http protocol which is secure method of passing information .<\/p>\n\n\n\n<p>3. <strong>PUT<\/strong> method<\/p>\n\n\n\n<p>It is an <a href=\"https:\/\/restfulapi.net\/idempotent-rest-apis\/\" rel=\"nofollow noopener\" target=\"_blank\">Idempotent method<\/a>, we can send multiple requests with PUT, but will not affect server and same request can be sent multiple times, it will update data. It tries to identify the resource with request.<\/p>\n\n\n\n<p>Consider an example to request using PUT in php<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/M9enk0vEEqYMnubTN0PKrOtWqKYWvaDjwofb_kqbmOIgFsMMAV9l_CJNgytjvxz79ggsLv3ji--Iy_xHiPdOQbH1u4eqiW1UAq4Q6QUn6dICBQ_GD2KR3MxgzpmGZGBXZ8KfwTfdtW-3rWj3GQ\" alt=\"\" title=\"\"><\/figure>\n\n\n\n<p>The client side request is sent as a blank request<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/M9enk0vEEqYMnubTN0PKrOtWqKYWvaDjwofb_kqbmOIgFsMMAV9l_CJNgytjvxz79ggsLv3ji--Iy_xHiPdOQbH1u4eqiW1UAq4Q6QUn6dICBQ_GD2KR3MxgzpmGZGBXZ8KfwTfdtW-3rWj3GQ\" alt=\"\" title=\"\"><\/figure>\n\n\n\n<p>The server side response will be like<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/PjSmqFC2h63fskjyRyXA-80i2h_Brg-ociIi_yLwrNE9nhNoI6wGoQQGbnVuGe1l6ZYNl5Yse6OWuWltI9F8CGmTQYFS2PndTBLffTL5rHwvoid9ISO2yg2p34MqFLjx1_3VDUoBLYwvcWxyCw\" alt=\"\" title=\"\"><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/PjSmqFC2h63fskjyRyXA-80i2h_Brg-ociIi_yLwrNE9nhNoI6wGoQQGbnVuGe1l6ZYNl5Yse6OWuWltI9F8CGmTQYFS2PndTBLffTL5rHwvoid9ISO2yg2p34MqFLjx1_3VDUoBLYwvcWxyCw\" alt=\"\" title=\"\"><\/figure>\n\n\n\n<p><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/orQCuhZX7AFHxyybnlgZ-YnHCkSwbjquVKxJgy2AHydWpxisYVxeFrhrgjRyH_5gT_X2Quy6ILTNus9PkMkUlo3nagGgYgZDs4nuV5M1TxF_bLx6RuxFNUsRpdDWFAYsdBoW_WmaIVaCrloEZA\" width=\"1081.86962556839\" height=\"369.9962022304535\" alt=\"\" title=\"\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>HTTP: is the Hypertext Transfer Protocol(HTTP) enables the communication between client and server. It has a request-response protocol for communication. The request sent by the client is responded by the server. The HTTP methods used are:&nbsp; GET POST PUT HEAD DELETE PATCH OPTIONS The set of commands are as follows: This article explains : GET, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":6663,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-6484","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\/6484","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=6484"}],"version-history":[{"count":0,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/posts\/6484\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/media\/6663"}],"wp:attachment":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/media?parent=6484"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/categories?post=6484"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/tags?post=6484"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}