forked from docs/doc-exports
Reviewed-by: Sabelnikov, Dmitriy <dmitriy.sabelnikov@t-systems.com> Co-authored-by: zhangyue <zhangyue164@huawei.com> Co-committed-by: zhangyue <zhangyue164@huawei.com>
186 lines
17 KiB
HTML
186 lines
17 KiB
HTML
<a name="obs_04_0007"></a><a name="obs_04_0007"></a>
|
|
|
|
<h1 class="topictitle1">Constructing a Request</h1>
|
|
<div id="body1540211758070"><p id="obs_04_0007__a43d1d1a130ea44338355338cae1cdf56">This section describes the structure of a REST API request.</p>
|
|
<div class="section" id="obs_04_0007__section1849899574"><h4 class="sectiontitle">Request URI</h4><p id="obs_04_0007__p61456874">OBS uses URI to locate specific buckets, objects, and their parameters. Use URIs when you want to operate resources.</p>
|
|
<p id="obs_04_0007__p16240961">The following provides a common URI format. The parameters in square brackets [ ] are optional.</p>
|
|
<p id="obs_04_0007__p12437161441413"><strong id="obs_04_0007__b111541655132712">protocol://<strong id="obs_04_0007__b6154155592713">[</strong>bucket.<strong id="obs_04_0007__b1915495512279">]</strong>domain[:port][/object][?param]</strong></p>
|
|
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="obs_04_0007__table40449485" frame="border" border="1" rules="all"><caption><b>Table 1 </b>URI parameters</caption><thead align="left"><tr id="obs_04_0007__row6511324"><th align="left" class="cellrowborder" valign="top" width="14.141414141414144%" id="mcps1.3.2.5.2.4.1.1"><p id="obs_04_0007__p57655222">Parameter</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="72.72727272727273%" id="mcps1.3.2.5.2.4.1.2"><p id="obs_04_0007__p39561425">Description</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="13.131313131313133%" id="mcps1.3.2.5.2.4.1.3"><p id="obs_04_0007__p50358869">Mandatory</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="obs_04_0007__row52536552"><td class="cellrowborder" valign="top" width="14.141414141414144%" headers="mcps1.3.2.5.2.4.1.1 "><p id="obs_04_0007__p27602357">protocol</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="72.72727272727273%" headers="mcps1.3.2.5.2.4.1.2 "><p id="obs_04_0007__p21198434">Protocol used for sending requests, which can be either HTTP or HTTPS. HTTPS is a protocol that ensures secure access to resources.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="13.131313131313133%" headers="mcps1.3.2.5.2.4.1.3 "><p id="obs_04_0007__p39351575">Yes</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="obs_04_0007__row88287534152"><td class="cellrowborder" valign="top" width="14.141414141414144%" headers="mcps1.3.2.5.2.4.1.1 "><p id="obs_04_0007__p1930030181620">bucket</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="72.72727272727273%" headers="mcps1.3.2.5.2.4.1.2 "><p id="obs_04_0007__p930030121615">Resource path of a bucket, identifying only one bucket in OBS</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="13.131313131313133%" headers="mcps1.3.2.5.2.4.1.3 "><p id="obs_04_0007__p3300803163">No</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="obs_04_0007__row55346801513"><td class="cellrowborder" valign="top" width="14.141414141414144%" headers="mcps1.3.2.5.2.4.1.1 "><p id="obs_04_0007__p135344812156">domain</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="72.72727272727273%" headers="mcps1.3.2.5.2.4.1.2 "><p id="obs_04_0007__p323103261516">Domain name or IP address of the server for saving resources</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="13.131313131313133%" headers="mcps1.3.2.5.2.4.1.3 "><p id="obs_04_0007__p125929367153">Yes</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="obs_04_0007__row53201908"><td class="cellrowborder" valign="top" width="14.141414141414144%" headers="mcps1.3.2.5.2.4.1.1 "><p id="obs_04_0007__p14387307">port</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="72.72727272727273%" headers="mcps1.3.2.5.2.4.1.2 "><p id="obs_04_0007__p24521247">Port enabled for protocols used for sending requests. The value varies with software server deployment. If no port number is specified, the protocol uses the default value. Each transmission protocol has its default port number.</p>
|
|
<p id="obs_04_0007__p25031604">In OBS, the default HTTP port number is <strong id="obs_04_0007__b10573105513402">80</strong> and that of HTTPS is <strong id="obs_04_0007__b1157335524014">443</strong>.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="13.131313131313133%" headers="mcps1.3.2.5.2.4.1.3 "><p id="obs_04_0007__p14294078">No</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="obs_04_0007__row35289195"><td class="cellrowborder" valign="top" width="14.141414141414144%" headers="mcps1.3.2.5.2.4.1.1 "><p id="obs_04_0007__p39852543">object</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="72.72727272727273%" headers="mcps1.3.2.5.2.4.1.2 "><p id="obs_04_0007__p6830580">An object path used in the request</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="13.131313131313133%" headers="mcps1.3.2.5.2.4.1.3 "><p id="obs_04_0007__p16406130">No</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="obs_04_0007__row13437443"><td class="cellrowborder" valign="top" width="14.141414141414144%" headers="mcps1.3.2.5.2.4.1.1 "><p id="obs_04_0007__p14691104">param</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="72.72727272727273%" headers="mcps1.3.2.5.2.4.1.2 "><p id="obs_04_0007__p49128794">A specific resource contained by a bucket or object. Default value of this parameter indicates that the bucket or object itself is obtained.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="13.131313131313133%" headers="mcps1.3.2.5.2.4.1.3 "><p id="obs_04_0007__p45866588">No</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<div class="notice" id="obs_04_0007__note449230598"><span class="noticetitle"><img src="public_sys-resources/notice_3.0-en-us.png"> </span><div class="noticebody"><p id="obs_04_0007__p169401149185116">All API requests except those for the bucket list must contain the bucket name. Based on the DNS resolution performance and reliability, OBS requires that the bucket name must be placed in front of the <strong id="obs_04_0007__b321515165217">domain</strong> when a request carrying a bucket name is constructed to form a third-level domain name, also mentioned as virtual hosting access domain name.</p>
|
|
<p id="obs_04_0007__p3688185011212">For example, you have a bucket named <strong id="obs_04_0007__b31131019248">test-bucket</strong> in the <strong id="obs_04_0007__b152410132414">a1</strong> region, and you want to access the ACL of an object named <strong id="obs_04_0007__b63151016247">test-object</strong> in the bucket. The correct URL is <strong id="obs_04_0007__b1831210172414">https://test-bucket.obs.a1.example.com/test-object?acl</strong>.</p>
|
|
</div></div>
|
|
</div>
|
|
<div class="section" id="obs_04_0007__section580035055419"><h4 class="sectiontitle">Request Method</h4><p id="obs_04_0007__p65661618145510">HTTP methods, which are also called operations or actions, specify the type of operations that you are requesting.</p>
|
|
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="obs_04_0007__table1123134922518" frame="border" border="1" rules="all"><caption><b>Table 2 </b>HTTP request methods supported by the OBS</caption><thead align="left"><tr id="obs_04_0007__row65706590"><th align="left" class="cellrowborder" valign="top" width="15.15%" id="mcps1.3.3.3.2.3.1.1"><p id="obs_04_0007__p20633546">Method</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="84.85000000000001%" id="mcps1.3.3.3.2.3.1.2"><p id="obs_04_0007__p60704555">Description</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="obs_04_0007__row18121961"><td class="cellrowborder" valign="top" width="15.15%" headers="mcps1.3.3.3.2.3.1.1 "><p id="obs_04_0007__p58592747">GET</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="84.85000000000001%" headers="mcps1.3.3.3.2.3.1.2 "><p id="obs_04_0007__p48392090">Requests that the server return a specific resource, for example, a bucket list or object.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="obs_04_0007__row32875629"><td class="cellrowborder" valign="top" width="15.15%" headers="mcps1.3.3.3.2.3.1.1 "><p id="obs_04_0007__p45680330">PUT</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="84.85000000000001%" headers="mcps1.3.3.3.2.3.1.2 "><p id="obs_04_0007__p9119239">Requests that the server update a specific resource, for example, creating a bucket or uploading an object.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="obs_04_0007__row14964289"><td class="cellrowborder" valign="top" width="15.15%" headers="mcps1.3.3.3.2.3.1.1 "><p id="obs_04_0007__p4147890">POST</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="84.85000000000001%" headers="mcps1.3.3.3.2.3.1.2 "><p id="obs_04_0007__p434775">Requests that the server add a resource or perform a special operation, for example, initiating multipart uploads or assembling parts.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="obs_04_0007__row35216792"><td class="cellrowborder" valign="top" width="15.15%" headers="mcps1.3.3.3.2.3.1.1 "><p id="obs_04_0007__p33987935">DELETE</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="84.85000000000001%" headers="mcps1.3.3.3.2.3.1.2 "><p id="obs_04_0007__p1559313">Requests that the server delete specified resources, for example, an object.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="obs_04_0007__row14033823"><td class="cellrowborder" valign="top" width="15.15%" headers="mcps1.3.3.3.2.3.1.1 "><p id="obs_04_0007__p62997855">HEAD</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="84.85000000000001%" headers="mcps1.3.3.3.2.3.1.2 "><p id="obs_04_0007__p2552640">Requests that the server return the description of a specific resource, for example, object metadata.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="obs_04_0007__row22973764"><td class="cellrowborder" valign="top" width="15.15%" headers="mcps1.3.3.3.2.3.1.1 "><p id="obs_04_0007__p48935609">OPTIONS</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="84.85000000000001%" headers="mcps1.3.3.3.2.3.1.2 "><p id="obs_04_0007__p4361378">Requests that the server check whether the user has the operation permission for a resource. The CORS needs to be configured for the bucket.</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="obs_04_0007__section1454211155819"><h4 class="sectiontitle">Request Headers</h4><p id="obs_04_0007__p155521124165511">Refers to optional and additional request fields, for example a field required by a specific URI or HTTP method. For details about the fields of common request headers, see <a href="#obs_04_0007__table25197309">Table 3</a>.</p>
|
|
|
|
<div class="tablenoborder"><a name="obs_04_0007__table25197309"></a><a name="table25197309"></a><table cellpadding="4" cellspacing="0" summary="" id="obs_04_0007__table25197309" frame="border" border="1" rules="all"><caption><b>Table 3 </b>Common request headers</caption><thead align="left"><tr id="obs_04_0007__row56260471"><th align="left" class="cellrowborder" valign="top" width="20.380000000000003%" id="mcps1.3.4.3.2.4.1.1"><p id="obs_04_0007__p60804269">Header</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="58.87%" id="mcps1.3.4.3.2.4.1.2"><p id="obs_04_0007__p26198756">Description</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="20.75%" id="mcps1.3.4.3.2.4.1.3"><p id="obs_04_0007__p41724483">Mandatory</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="obs_04_0007__row24239987"><td class="cellrowborder" valign="top" width="20.380000000000003%" headers="mcps1.3.4.3.2.4.1.1 "><p id="obs_04_0007__p17281948">Authorization</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="58.87%" headers="mcps1.3.4.3.2.4.1.2 "><p id="obs_04_0007__p57660517">Signature information contained in a request message</p>
|
|
<p id="obs_04_0007__p49182605">Type: string</p>
|
|
<p id="obs_04_0007__p39990262">No default value.</p>
|
|
<p id="obs_04_0007__p24368041">Conditional: optional for anonymous requests and required for other requests.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="20.75%" headers="mcps1.3.4.3.2.4.1.3 "><p id="obs_04_0007__p27654330">Conditionally required</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="obs_04_0007__row47562386"><td class="cellrowborder" valign="top" width="20.380000000000003%" headers="mcps1.3.4.3.2.4.1.1 "><p id="obs_04_0007__p27348077">Content-Length</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="58.87%" headers="mcps1.3.4.3.2.4.1.2 "><p id="obs_04_0007__p601777">The message length (excluding headers) defined in RFC 2616</p>
|
|
<p id="obs_04_0007__p5415993">Type: string</p>
|
|
<p id="obs_04_0007__p48743940">No default value.</p>
|
|
<p id="obs_04_0007__p36042284">Conditional: optional for PUT requests, but mandatory for the requests that load XML content</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="20.75%" headers="mcps1.3.4.3.2.4.1.3 "><p id="obs_04_0007__p33743900">Conditionally required</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="obs_04_0007__row35259646"><td class="cellrowborder" valign="top" width="20.380000000000003%" headers="mcps1.3.4.3.2.4.1.1 "><p id="obs_04_0007__p37459059">Content-Type</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="58.87%" headers="mcps1.3.4.3.2.4.1.2 "><p id="obs_04_0007__p14284953">The content type of the requested resource, for example, <strong id="obs_04_0007__b17772351">text</strong>/<strong id="obs_04_0007__b25733436">plain</strong></p>
|
|
<p id="obs_04_0007__p61455718">Type: string</p>
|
|
<p id="obs_04_0007__p16230551">No default value.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="20.75%" headers="mcps1.3.4.3.2.4.1.3 "><p id="obs_04_0007__p39606294">No</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="obs_04_0007__row20912334"><td class="cellrowborder" valign="top" width="20.380000000000003%" headers="mcps1.3.4.3.2.4.1.1 "><p id="obs_04_0007__p16177456">Date</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="58.87%" headers="mcps1.3.4.3.2.4.1.2 "><p id="obs_04_0007__p35305575">Time when a request is initiated, for example, <strong id="obs_04_0007__b12662139205219">Wed, 27 Jun 2018 13:39:15 +0000</strong>.</p>
|
|
<p id="obs_04_0007__p49314726">Type: string</p>
|
|
<p id="obs_04_0007__p41179355">No default value.</p>
|
|
<p id="obs_04_0007__p35069879">Conditional: optional for anonymous requests or those requests containing header <strong id="obs_04_0007__b109335711495028">x-obs-date</strong>, required for other requests.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="20.75%" headers="mcps1.3.4.3.2.4.1.3 "><p id="obs_04_0007__p22087952">Conditionally required</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="obs_04_0007__row64573848"><td class="cellrowborder" valign="top" width="20.380000000000003%" headers="mcps1.3.4.3.2.4.1.1 "><p id="obs_04_0007__p63099185">Host</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="58.87%" headers="mcps1.3.4.3.2.4.1.2 "><p id="obs_04_0007__p97201251192612">The host address, for example, <em id="obs_04_0007__i091915516116">bucketname</em><strong id="obs_04_0007__b103833581118">.obs.</strong><em id="obs_04_0007__i1503348161018">region</em><strong id="obs_04_0007__b135035483101">.example.com</strong>.</p>
|
|
<p id="obs_04_0007__p29734368">Type: string</p>
|
|
<p id="obs_04_0007__p66282721">No default value.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="20.75%" headers="mcps1.3.4.3.2.4.1.3 "><p id="obs_04_0007__p191303">Yes</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="obs_04_0007__section14612192315587"><h4 class="sectiontitle">(Optional) Request Body</h4><p id="obs_04_0007__p23132011213">A request body is generally sent in a structured format (for example, JSON or XML). It corresponds to <strong id="obs_04_0007__b367972613329">Content-Type</strong> in the request header and is used to transfer content other than the request header. If the request body contains full-width characters, these characters must be coded using UTF-8.</p>
|
|
<p id="obs_04_0007__p43235913117">The request body varies according to the APIs. Certain APIs do not require the request body, such as the GET and DELETE APIs.</p>
|
|
</div>
|
|
<div class="section" id="obs_04_0007__section140743661613"><h4 class="sectiontitle">Sending a Request</h4><p id="obs_04_0007__abe87411d02f441d8acf5a5f63d52edbe">There are two methods to initiate requests based on the constructed request messages:</p>
|
|
<ul id="obs_04_0007__u69bb0fd8d11a4e428f4e6fedc1515950"><li id="obs_04_0007__la8e5f209e37b4c9eb0ae66f73d0ec1f0">cURL<p id="obs_04_0007__a04f9f8ebd6674f36b25f63e65a92dcf2"><a name="obs_04_0007__la8e5f209e37b4c9eb0ae66f73d0ec1f0"></a><a name="la8e5f209e37b4c9eb0ae66f73d0ec1f0"></a>cURL is a command-line tool used to perform URL operations and transmit information. cURL acts as an HTTP client that can send HTTP requests to the server and receive response messages. cURL is applicable to API debugging. For more information about cURL, visit <a href="https://curl.haxx.se/" target="_blank" rel="noopener noreferrer">https://curl.haxx.se/</a>. cURL cannot calculate signatures. When cURL is used, only anonymous public OBS resources can be accessed.</p>
|
|
</li><li id="obs_04_0007__lae3f7b6d508b43cd8565d0e8c4d9700b">Coding<p id="obs_04_0007__a02b0199016c4467693bc9cd4dcd9d74f"><a name="obs_04_0007__lae3f7b6d508b43cd8565d0e8c4d9700b"></a><a name="lae3f7b6d508b43cd8565d0e8c4d9700b"></a>You can use code to make API calls, and to assemble, send, and process request messages. It can be implemented by using the SDK or coding.</p>
|
|
</li></ul>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="obs_04_0006.html">Calling APIs</a></div>
|
|
</div>
|
|
</div>
|
|
|