forked from docs/doc-exports
Reviewed-by: Kacur, Michal <michal.kacur@t-systems.com> Co-authored-by: Xiong, Chen Xiao <chenxiaoxiong@huawei.com> Co-committed-by: Xiong, Chen Xiao <chenxiaoxiong@huawei.com>
196 lines
23 KiB
HTML
196 lines
23 KiB
HTML
<a name="dis_02_0400"></a><a name="dis_02_0400"></a>
|
|
|
|
<h1 class="topictitle1">Making an API Request</h1>
|
|
<div id="body8662426"><p id="dis_02_0400__en-us_topic_0121682347_p15648656678">This section describes the structure of a REST API request, and uses the IAM API for <a href="https://docs.otc.t-systems.com/en-us/api/iam/en-us_topic_0057845583.html" target="_blank" rel="noopener noreferrer">obtaining a user token</a> as an example to demonstrate how to call an API. The obtained token can then be used to authenticate the calling of other APIs.</p>
|
|
<div class="section" id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_section697653216219"><h4 class="sectiontitle">Request URI</h4><p id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_p1327834192114">A request URI is in the following format:</p>
|
|
<p id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_p015994616212"><strong id="dis_02_0400__b182541054151212">{URI-scheme}://{Endpoint}/{resource-path}?{query-string}</strong></p>
|
|
<p id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_p16960034182113">Although a request URI is included in the request header, most programming languages or frameworks require the request URI to be transmitted separately.</p>
|
|
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_table4443194632512" width="100%" frame="border" border="1" rules="all"><caption><b>Table 1 </b>URI parameter description</caption><thead align="left"><tr id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_row1944414616258"><th align="left" class="cellrowborder" valign="top" width="19.48%" id="mcps1.3.2.5.2.3.1.1"><p id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_p1644484692510"><strong id="dis_02_0400__en-us_topic_0121682347_b23574928194256">Parameter</strong></p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="80.52%" id="mcps1.3.2.5.2.3.1.2"><p id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_p174441146142511"><strong id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_b131565362615">Description</strong></p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_row10444144620259"><td class="cellrowborder" valign="top" width="19.48%" headers="mcps1.3.2.5.2.3.1.1 "><p id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_p154446465251">URI-scheme</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="80.52%" headers="mcps1.3.2.5.2.3.1.2 "><p id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_p8444144692517">Protocol used to transmit requests. All APIs use HTTPS.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_row444414692513"><td class="cellrowborder" valign="top" width="19.48%" headers="mcps1.3.2.5.2.3.1.1 "><p id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_p7444194610257">Endpoint</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="80.52%" headers="mcps1.3.2.5.2.3.1.2 "><p id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_p244474613259">Domain name or IP address of the server bearing the REST service. The endpoint varies between services in different regions. It can be obtained from <a href="https://docs.otc.t-systems.com/en-us/endpoint/index.html" target="_blank" rel="noopener noreferrer">Regions and Endpoints</a>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_row1744454612520"><td class="cellrowborder" valign="top" width="19.48%" headers="mcps1.3.2.5.2.3.1.1 "><p id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_p14442468257">resource-path</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="80.52%" headers="mcps1.3.2.5.2.3.1.2 "><p id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_p1844412467258">Access path of an API for performing a specified operation. Obtain the path from the URI of an API. For example, the <strong id="dis_02_0400__b598026563">resource-path</strong> of the API used to obtain a user token is <span class="parmvalue" id="dis_02_0400__parmvalue11981361063"><b>/v3/auth/tokens</b></span>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_row184441346152515"><td class="cellrowborder" valign="top" width="19.48%" headers="mcps1.3.2.5.2.3.1.1 "><p id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_p4444154692516">query-string</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="80.52%" headers="mcps1.3.2.5.2.3.1.2 "><p id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_p1444414622514">Query parameter, which is optional. Ensure that a question mark (?) is included before each query parameter that is in the format of "<em id="dis_02_0400__i9336125020386">Parameter name=Parameter value</em>". For example, <strong id="dis_02_0400__b1190023920610">? limit=10</strong> indicates that a maximum of 10 data records will be displayed.</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<div class="note" id="dis_02_0400__en-us_topic_0121682347_note16311253154112"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="dis_02_0400__en-us_topic_0121682347_p163316534416">To simplify the URI display in this document, each API is provided only with a <strong id="dis_02_0400__b820034019189">resource-path</strong> and a request method. The <strong id="dis_02_0400__b10554195594520">URI-scheme</strong> of all APIs is <strong id="dis_02_0400__b10736622464">HTTPS</strong>, and the endpoints of all APIs in the same region are identical.</p>
|
|
</div></div>
|
|
</div>
|
|
<div class="section" id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_section5296154118345"><h4 class="sectiontitle">Request Methods</h4><div class="p" id="dis_02_0400__en-us_topic_0121682347_p46347563325">The HTTP protocol defines the following request methods that can be used to send a request to the server:
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_table1961229113819" frame="border" border="1" rules="all"><caption><b>Table 2 </b>HTTP methods</caption><thead align="left"><tr id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_row86141913816"><th align="left" class="cellrowborder" valign="top" width="30%" id="mcps1.3.3.2.1.2.3.1.1"><p id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_p186147910387"><strong id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_b1093312238395">Method</strong></p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="70%" id="mcps1.3.3.2.1.2.3.1.2"><p id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_p166141293387"><strong id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_b169341023133919">Description</strong></p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_row146141194381"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.3.2.1.2.3.1.1 "><p id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_p12831539123914">GET</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.3.2.1.2.3.1.2 "><p id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_p2831123916397">Requests the server to return specified resources.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_row161429103817"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.3.2.1.2.3.1.1 "><p id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_p3831239183912">PUT</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.3.2.1.2.3.1.2 "><p id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_p178311939193911">Requests the server to update specified resources.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_row56141190384"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.3.2.1.2.3.1.1 "><p id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_p68311239113912">POST</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.3.2.1.2.3.1.2 "><p id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_p1583133918391">Requests the server to add resources or perform special operations.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_row861411903812"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.3.2.1.2.3.1.1 "><p id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_p1183153943916">DELETE</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.3.2.1.2.3.1.2 "><p id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_p6831163914392">Requests the server to delete specified resources, for example, an object.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_row5614119183810"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.3.2.1.2.3.1.1 "><p id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_p78314395393">HEAD</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.3.2.1.2.3.1.2 "><p id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_p38311239153920">Same as GET except that the server must return only the response header.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_row2614199163812"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.3.2.1.2.3.1.1 "><p id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_p1483143915390">PATCH</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.3.2.1.2.3.1.2 "><p id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_p17831173918394">Requests the server to update partial content of a specified resource.</p>
|
|
<p id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_p9831123911390">If the resource does not exist, a new resource will be created.</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<p id="dis_02_0400__en-us_topic_0121682347_p3759142614815">For example, in the case of the API used to <a href="https://docs.otc.t-systems.com/en-us/api/iam/en-us_topic_0057845583.html" target="_blank" rel="noopener noreferrer">obtain a user token</a>, the request method is <span class="parmname" id="dis_02_0400__parmname147931122102111"><b>POST</b></span>, and the request is as follows:</p>
|
|
</div>
|
|
<div class="section" id="dis_02_0400__en-us_topic_0121682347_section479119143310"><h4 class="sectiontitle">Request Header</h4><p id="dis_02_0400__en-us_topic_0121682347_p269363935616">You can also add additional header fields to a request, such as the fields required by a specified URI or HTTP method. For example, to request for the authentication information, add <span class="parmname" id="dis_02_0400__parmname206577276277"><b>Content-Type</b></span>, which specifies the request body type.</p>
|
|
<div class="p" id="dis_02_0400__en-us_topic_0121682347_p56967114331"><a href="#dis_02_0400__en-us_topic_0121682347_table1986821153312">Table 3</a> lists common request headers.
|
|
<div class="tablenoborder"><a name="dis_02_0400__en-us_topic_0121682347_table1986821153312"></a><a name="en-us_topic_0121682347_table1986821153312"></a><table cellpadding="4" cellspacing="0" summary="" id="dis_02_0400__en-us_topic_0121682347_table1986821153312" frame="border" border="1" rules="all"><caption><b>Table 3 </b>Common request headers</caption><thead align="left"><tr id="dis_02_0400__en-us_topic_0121682347_row1286841153311"><th align="left" class="cellrowborder" valign="top" width="19.74%" id="mcps1.3.4.3.2.2.5.1.1"><p id="dis_02_0400__en-us_topic_0121682347_p178680183310"><strong id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_b1355613001117">Parameter</strong></p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="26.5%" id="mcps1.3.4.3.2.2.5.1.2"><p id="dis_02_0400__en-us_topic_0121682347_p78688118335"><strong id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_b612662015512">Description</strong></p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="20.11%" id="mcps1.3.4.3.2.2.5.1.3"><p id="dis_02_0400__en-us_topic_0121682347_p58686123316"><strong id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_b812872012519">Mandatory</strong></p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="33.650000000000006%" id="mcps1.3.4.3.2.2.5.1.4"><p id="dis_02_0400__en-us_topic_0121682347_p48681314333"><strong id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_b812932085119">Example</strong></p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="dis_02_0400__en-us_topic_0121682347_row1286861153311"><td class="cellrowborder" valign="top" width="19.74%" headers="mcps1.3.4.3.2.2.5.1.1 "><p id="dis_02_0400__en-us_topic_0121682347_p2086813163316">Host</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="26.5%" headers="mcps1.3.4.3.2.2.5.1.2 "><p id="dis_02_0400__en-us_topic_0121682347_p58681814333">Specifies the server domain name and port number of the resources being requested. The value can be obtained from the URL of the service API. The value is in the format of <em id="dis_02_0400__en-us_topic_0121682347_i1012185414574">Hostname:Port number</em>. If the port number is not specified, the default port is used. The default port number for HTTPS is 443.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="20.11%" headers="mcps1.3.4.3.2.2.5.1.3 "><p id="dis_02_0400__en-us_topic_0121682347_p886815123319">No</p>
|
|
<p id="dis_02_0400__en-us_topic_0121682347_p386811116333">This field is mandatory for AK/SK authentication.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="33.650000000000006%" headers="mcps1.3.4.3.2.2.5.1.4 "><p id="dis_02_0400__en-us_topic_0121682347_p486814118330">code.test.com</p>
|
|
<p id="dis_02_0400__en-us_topic_0121682347_p5868161163317">or</p>
|
|
<p id="dis_02_0400__en-us_topic_0121682347_p786841123315">code.test.com:443</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dis_02_0400__en-us_topic_0121682347_row386818143313"><td class="cellrowborder" valign="top" width="19.74%" headers="mcps1.3.4.3.2.2.5.1.1 "><p id="dis_02_0400__en-us_topic_0121682347_p118689123320">Content-Type</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="26.5%" headers="mcps1.3.4.3.2.2.5.1.2 "><p id="dis_02_0400__en-us_topic_0121682347_p1486815116337">Specifies the request body MIME type. Its default value is <strong id="dis_02_0400__b199163912328">application/json</strong>. Other values of this field will be provided for specific APIs if any.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="20.11%" headers="mcps1.3.4.3.2.2.5.1.3 "><p id="dis_02_0400__en-us_topic_0121682347_p1086812114335">Yes</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="33.650000000000006%" headers="mcps1.3.4.3.2.2.5.1.4 "><p id="dis_02_0400__en-us_topic_0121682347_p1186841163310">application/json</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dis_02_0400__en-us_topic_0121682347_row11868419337"><td class="cellrowborder" valign="top" width="19.74%" headers="mcps1.3.4.3.2.2.5.1.1 "><p id="dis_02_0400__en-us_topic_0121682347_p178687119330">Content-Length</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="26.5%" headers="mcps1.3.4.3.2.2.5.1.2 "><p id="dis_02_0400__en-us_topic_0121682347_p178681813332">Specifies the length of the request body. The unit is byte.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="20.11%" headers="mcps1.3.4.3.2.2.5.1.3 "><p id="dis_02_0400__en-us_topic_0121682347_p18687183316">No</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="33.650000000000006%" headers="mcps1.3.4.3.2.2.5.1.4 "><p id="dis_02_0400__en-us_topic_0121682347_p148689110334">3495</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dis_02_0400__en-us_topic_0121682347_row2868171143313"><td class="cellrowborder" valign="top" width="19.74%" headers="mcps1.3.4.3.2.2.5.1.1 "><p id="dis_02_0400__en-us_topic_0121682347_p586815118338">X-Project-Id</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="26.5%" headers="mcps1.3.4.3.2.2.5.1.2 "><p id="dis_02_0400__en-us_topic_0121682347_p1586811163312">Specifies the project ID. Obtain the project ID by following the instructions in <a href="dis_02_0501.html">Obtaining a Project ID</a>.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="20.11%" headers="mcps1.3.4.3.2.2.5.1.3 "><p id="dis_02_0400__en-us_topic_0121682347_p886812110335">No</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="33.650000000000006%" headers="mcps1.3.4.3.2.2.5.1.4 "><p id="dis_02_0400__en-us_topic_0121682347_p198684143315">e9993fc787d94b6c886cbaa340f9c0f4</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dis_02_0400__en-us_topic_0121682347_row188688113337"><td class="cellrowborder" valign="top" width="19.74%" headers="mcps1.3.4.3.2.2.5.1.1 "><p id="dis_02_0400__en-us_topic_0121682347_p198684111335">X-Auth-Token</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="26.5%" headers="mcps1.3.4.3.2.2.5.1.2 "><p id="dis_02_0400__en-us_topic_0121682347_p1086851153317">Specifies the user token.</p>
|
|
<p id="dis_02_0400__en-us_topic_0121682347_p1057635831">It is a response to the API used to <a href="https://docs.otc.t-systems.com/en-us/api/iam/en-us_topic_0057845583.html" target="_blank" rel="noopener noreferrer">obtain a user token</a>. This API is the only one that does not require authentication.</p>
|
|
<p id="dis_02_0400__en-us_topic_0121682347_p15868417337">After the request is processed, the value of <strong id="dis_02_0400__en-us_topic_0121682347_b842352706205322">X-Subject-Token</strong> in the header is the token value.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="20.11%" headers="mcps1.3.4.3.2.2.5.1.3 "><p id="dis_02_0400__en-us_topic_0121682347_p4868514338">No</p>
|
|
<p id="dis_02_0400__en-us_topic_0121682347_p986818114339">This field is mandatory for token authentication.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="33.650000000000006%" headers="mcps1.3.4.3.2.2.5.1.4 "><p id="dis_02_0400__en-us_topic_0121682347_p27152505302">The following is part of an example token:</p>
|
|
<p id="dis_02_0400__en-us_topic_0121682347_p168689113318">MIIPAgYJKoZIhvcNAQcCo...ggg1BBIINPXsidG9rZ</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="note" id="dis_02_0400__en-us_topic_0121682347_note13771123325011"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="dis_02_0400__en-us_topic_0121682347_p1513412221808">In addition to supporting token-based authentication, APIs also support authentication using access key ID/secret access key (AK/SK). During AK/SK-based authentication, an SDK is used to sign the request, and the <strong id="dis_02_0400__b8527154483716">Authorization</strong> (signature authentication) and <strong id="dis_02_0400__b155271844183712">X-Sdk-Date</strong> (time when the request is sent) header fields are automatically added to the request.</p>
|
|
<p id="dis_02_0400__en-us_topic_0121682347_p1577123365010">For more information, see "AK/SK-based Authentication" in <a href="dis_02_0517.html">Authentication</a>.</p>
|
|
</div></div>
|
|
<p id="dis_02_0400__en-us_topic_0121682347_p42118461957">The API used to <a href="https://docs.otc.t-systems.com/en-us/api/iam/en-us_topic_0057845583.html" target="_blank" rel="noopener noreferrer">obtain a user token</a> does not require authentication. Therefore, only the <strong id="dis_02_0400__b11129315410">Content-Type</strong> field needs to be added to requests for calling the API. An example of such requests is as follows:</p>
|
|
</div>
|
|
<div class="section" id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_section1437471411"><h4 class="sectiontitle">(Optional) Request Body</h4><p id="dis_02_0400__en-us_topic_0121682347_en-us_topic_0113746487_p76011911717">This part is optional. The body of a request is often sent in a structured format as specified in the <strong id="dis_02_0400__en-us_topic_0121682347_b38611615439">Content-Type</strong> header field, such as JSON or XML. The request body transfers content except the request header.</p>
|
|
<p id="dis_02_0400__en-us_topic_0121682347_p1847214711331">The request body varies between APIs. Some APIs do not require the request body, such as the APIs requested using the GET and DELETE methods.</p>
|
|
<p id="dis_02_0400__en-us_topic_0121682347_p105261225101112">In the case of the API used to <a href="https://docs.otc.t-systems.com/en-us/api/iam/en-us_topic_0057845583.html" target="_blank" rel="noopener noreferrer">obtain a user token</a>, the request parameters and parameter description can be obtained from the API request. The following provides an example request with a body included. Replace <em id="dis_02_0400__i333916502285">username</em>, <em id="dis_02_0400__i191111557142817">domainname</em>, <em id="dis_02_0400__i29811262919">********</em> (login password), and <em id="dis_02_0400__i167401714102917">xxxxxxxxxxxxxxxxxx</em> (project ID) with the actual values. To learn how to obtain a project ID, see <a href="dis_02_0501.html">Obtaining a Project ID</a>.</p>
|
|
<div class="note" id="dis_02_0400__en-us_topic_0121682347_note15403511418"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="dis_02_0400__en-us_topic_0121682347_p199011223194814">The <strong id="dis_02_0400__b468390193112">scope</strong> parameter specifies where a token takes effect. In the following example, the token takes effect only for the resources in a specified project. You can set <strong id="dis_02_0400__b960215521336">scope</strong> to a domain or a project under a domain. In the following example, the token takes effect only for the resources in a specified project. For more information about this API, see <a href="https://docs.otc.t-systems.com/en-us/api/iam/en-us_topic_0057845583.html" target="_blank" rel="noopener noreferrer">obtaining a user token</a>.</p>
|
|
</div></div>
|
|
<pre class="screen" id="dis_02_0400__en-us_topic_0121682347_screen6140617194816">Content-Type: application/json
|
|
{
|
|
"auth": {
|
|
"identity": {
|
|
"methods": [
|
|
"password"
|
|
],
|
|
"password": {
|
|
"user": {
|
|
"name": "<em id="dis_02_0400__en-us_topic_0121682347_i315217719194"><strong id="dis_02_0400__en-us_topic_0121682347_b14500116161919">username</strong></em>",
|
|
"password": "<strong id="dis_02_0400__en-us_topic_0121682347_b2559181251918"><em id="dis_02_0400__en-us_topic_0121682347_i12803128192">********</em></strong>",
|
|
"domain": {
|
|
"name": "<em id="dis_02_0400__en-us_topic_0121682347_i1560271681911"><strong id="dis_02_0400__en-us_topic_0121682347_b17173191614194">domainname</strong></em>"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"scope": {
|
|
"project": {
|
|
"name": "<strong id="dis_02_0400__en-us_topic_0121682347_b1261200101711"><em id="dis_02_0400__en-us_topic_0121682347_i186128061711">xxxxxxxxxxxxxxxxxx</em></strong>"
|
|
}
|
|
}
|
|
}
|
|
}</pre>
|
|
<p id="dis_02_0400__en-us_topic_0121682347_p1859663401915">If all data required for the API request is available, you can send the request to call the API through <a href="https://curl.haxx.se/" target="_blank" rel="noopener noreferrer">curl</a>, <a href="https://www.getpostman.com/" target="_blank" rel="noopener noreferrer">Postman</a>, or coding. In the response to the API used to obtain a user token, <strong id="dis_02_0400__b8575353124717">x-subject-token</strong> is the desired user token. This token can then be used to authenticate the calling of other APIs.</p>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="dis_02_0516.html">Calling APIs</a></div>
|
|
</div>
|
|
</div>
|
|
|