forked from magento/devdocs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhttp_methods.html
90 lines (48 loc) · 4.07 KB
/
http_methods.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
---
layout: m1x_rest
title: HTTP Methods
---
<ul class="introduction-menu">
<li><a href='#HTTPMethods-GET'>GET</a></li>
<li><a href='#HTTPMethods-POSTandPUT'>POST and PUT</a></li>
<li><a href='#HTTPMethods-DELETE'>DELETE</a></li>
</ul>
<p>Accessing API is performed via HTTP. When you enter a URL into a web browser address bar, the browser performs an HTTP GET request to the URL. This usually returns a web page in the form of an HTTP response that the browser displays. But the GET method is one of several HTTP request methods. Magento REST API uses the four main HTTP methods: GET, POST, PUT, and DELETE. The most widespread methods are GET and POST. The other methods are less known but they became widely known due to the popularity of REST web services. An important concept of the REST architecture is that different HTTP request methods perform different actions when applied to the same URL.</p>
<p>For example:</p>
<div class='panelMacro'><table class='infoMacro'><tr><td>GET <a href="https://magentohost/rest/customers/123">https://magentohost/rest/customers/123</a></td></tr></table></div>
<p>will retrieve information about the specified customer;</p>
<div class='panelMacro'><table class='infoMacro'><tr><td>DELETE <a href="https://magentohost/rest/customers/123">https://magentohost/rest/customers/123</a></td></tr></table></div>
<p>will delete the specified customer.</p>
<h2><a name="HTTPMethods-GET"></a>GET</h2>
<p><b>Retrieving Resources with the HTTP GET Method</b></p>
<p>The HTTP GET method is defined in section 9.3 of the <a href="http://www.ietf.org/rfc/rfc2616.txt">RFC2616</a> document:</p>
<blockquote>
<p>The GET method means retrieve whatever information (in the form of an entity) is identified by the Request-URI. If the Request-URI refers to a data-producing process, it is the produced data which shall be returned as the entity in the response and not the source text of the process, unless that text happens to be the output of the process.</p></blockquote>
<p>You can retrieve a representation of a resource by GETting its URL.</p>
<h2><a name="HTTPMethods-POSTandPUT"></a>POST and PUT</h2>
<p><b>Creating or Updating Resources with the HTTP POST and PUT Methods</b></p>
<p>The POST method is defined in section 9.5 of the <a href="http://www.ietf.org/rfc/rfc2616.txt">RFC2616</a> document:</p>
<blockquote>
<p>The POST method is used to request that the origin server accept the entity enclosed in the request as a new subordinate of the resource identified by the Request-URI in the Request-Line. POST is designed to allow a uniform method to cover the following functions:</p>
<ul>
<li>Annotation of existing resources;</li>
</ul>
<ul>
<li>Posting a message to a bulletin board, newsgroup, mailing list, or similar group of articles;</li>
</ul>
<ul>
<li>Providing a block of data, such as the result of submitting a form, to a data-handling process;</li>
</ul>
<ul>
<li>Extending a database through an append operation.</li>
</ul>
</blockquote>
<p>The PUT method is defined in section 9.6 of the <a href="http://www.ietf.org/rfc/rfc2616.txt">RFC2616</a> document:</p>
<blockquote><p>The PUT method requests that the enclosed entity be stored under the supplied Request-URI. If the Request-URI refers to an already existing resource, the enclosed entity SHOULD be considered as a modified version of the one residing on the origin server.</p></blockquote>
<p>Creating or updating a resource involves performing an HTTP POST or HTTP PUT to a resource URL.</p>
<h2><a name="HTTPMethods-DELETE"></a>DELETE</h2>
<p><b>Deleting Resources with the HTTP DELETE Method</b></p>
<p>The DELETE method is defined in section 9.7 of the <a href="http://www.ietf.org/rfc/rfc2616.txt">RFC2616</a> document:</p>
<blockquote><p>The DELETE method requests that the origin server delete the resource identified by the Request-URI. This method MAY be overridden by human intervention (or other means) on the origin server.</p></blockquote>
<p>Deleting a resource is performed by means of making an HTTP DELETE request to the resource URL.</p>
<?php include(__ROOT__ . 'footer.php'); ?>