1
0
forked from docs/doc-exports
Xiong, Chen Xiao 14a6d65e8c DataArts API 20240130 version
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com>
Co-authored-by: Xiong, Chen Xiao <chenxiaoxiong@huawei.com>
Co-committed-by: Xiong, Chen Xiao <chenxiaoxiong@huawei.com>
2024-03-01 11:46:15 +00:00

249 lines
33 KiB
HTML

<a name="making_request"></a><a name="making_request"></a>
<h1 class="topictitle1">Making an API Request</h1>
<div id="body8662426"><p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_p15648656678">This section describes the structure of a REST API, and uses the IAM API for obtaining a user token 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="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_en-us_topic_0113746487_section697653216219"><h4 class="sectiontitle">Request URI</h4><p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_en-us_topic_0113746487_p1327834192114">A request URI is in the following format:</p>
<p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_en-us_topic_0113746487_p015994616212"><strong id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_en-us_topic_0113746487_b11186155382110">{URI-scheme}://{Endpoint}/{resource-path}?{query-string}</strong></p>
<p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_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="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_en-us_topic_0113746487_table4443194632512" frame="border" border="1" rules="all"><caption><b>Table 1 </b>URI parameters</caption><thead align="left"><tr id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_en-us_topic_0113746487_row1944414616258"><th align="left" class="cellrowborder" valign="top" width="19.509999999999998%" id="mcps1.3.2.5.2.3.1.1"><p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_en-us_topic_0113746487_p1644484692510">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="80.49%" id="mcps1.3.2.5.2.3.1.2"><p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_en-us_topic_0113746487_p174441146142511">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_en-us_topic_0113746487_row10444144620259"><td class="cellrowborder" valign="top" width="19.509999999999998%" headers="mcps1.3.2.5.2.3.1.1 "><p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_en-us_topic_0113746487_p154446465251">URI-scheme</p>
</td>
<td class="cellrowborder" valign="top" width="80.49%" headers="mcps1.3.2.5.2.3.1.2 "><p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_en-us_topic_0113746487_p8444144692517">Protocol used to transmit requests. All APIs use HTTPS.</p>
</td>
</tr>
<tr id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_en-us_topic_0113746487_row444414692513"><td class="cellrowborder" valign="top" width="19.509999999999998%" headers="mcps1.3.2.5.2.3.1.1 "><p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_en-us_topic_0113746487_p7444194610257">Endpoint</p>
</td>
<td class="cellrowborder" valign="top" width="80.49%" headers="mcps1.3.2.5.2.3.1.2 "><p id="making_request__p114423095115">Domain name or IP address of the server bearing the REST service endpoint. The endpoint varies between services in different regions.</p>
<p id="making_request__p943125235818">An endpoint is the <strong id="making_request__en-us_topic_0000001716158229_b16300195371816">request address</strong> for calling an API. Endpoints vary depending on services and regions. You can obtain endpoints of the service 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="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_en-us_topic_0113746487_row1744454612520"><td class="cellrowborder" valign="top" width="19.509999999999998%" headers="mcps1.3.2.5.2.3.1.1 "><p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_en-us_topic_0113746487_p14442468257">resource-path</p>
</td>
<td class="cellrowborder" valign="top" width="80.49%" headers="mcps1.3.2.5.2.3.1.2 "><p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_en-us_topic_0113746487_p1844412467258">Access path of an API for performing a specified operation. Obtain the value from the URI of an API. For example, the <strong id="making_request__en-us_topic_0181281315_b42619432545">resource-path</strong> of the API used to obtain a user token is <span class="parmvalue" id="making_request__en-us_topic_0181281315_parmvalue12621643185414"><b>/v3/auth/tokens</b></span>.</p>
</td>
</tr>
<tr id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_en-us_topic_0113746487_row184441346152515"><td class="cellrowborder" valign="top" width="19.509999999999998%" headers="mcps1.3.2.5.2.3.1.1 "><p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_en-us_topic_0113746487_p4444154692516">query-string</p>
</td>
<td class="cellrowborder" valign="top" width="80.49%" headers="mcps1.3.2.5.2.3.1.2 "><p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_en-us_topic_0113746487_p1444414622514">Query parameter, which is optional. Ensure that a question mark (<span class="parmname" id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_parmname1580211351239"><b>?</b></span>) is included before each query parameter that is in the format of "<em id="making_request__en-us_topic_0181281315_i5406720122220">Parameter name=Parameter value</em>", for example, <span class="parmname" id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_parmname250193215285"><b>?limit=10</b></span>, it indicates that a maximum of 10 data records are allowed.</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="note" id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_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="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_p163316534416">To simplify the URI display in this document, each API is provided only with a <strong id="making_request__en-us_topic_0181281315_b82885116593">resource-path</strong> and a request method. The <strong id="making_request__en-us_topic_0181281315_b07852063011">URI-scheme</strong> value of all APIs is <strong id="making_request__en-us_topic_0181281315_b14786662020">HTTPS</strong>, and the endpoints of all APIs in the same region are identical.</p>
</div></div>
</div>
<div class="section" id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_en-us_topic_0113746487_section5296154118345"><h4 class="sectiontitle">Request Method</h4><div class="p" id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_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="making_request__en-us_topic_0181281315_en-us_topic_0170647348_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="making_request__en-us_topic_0181281315_en-us_topic_0170647348_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="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_en-us_topic_0113746487_p186147910387"><strong id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_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="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_en-us_topic_0113746487_p166141293387"><strong id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_en-us_topic_0113746487_b169341023133919">Description</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_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="making_request__en-us_topic_0181281315_en-us_topic_0170647348_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="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_en-us_topic_0113746487_p2831123916397">Requests the server to return specified resources.</p>
</td>
</tr>
<tr id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_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="making_request__en-us_topic_0181281315_en-us_topic_0170647348_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="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_en-us_topic_0113746487_p178311939193911">Requests the server to update specified resources.</p>
</td>
</tr>
<tr id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_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="making_request__en-us_topic_0181281315_en-us_topic_0170647348_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="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_en-us_topic_0113746487_p1583133918391">Requests the server to add resources or perform special operations.</p>
</td>
</tr>
<tr id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_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="making_request__en-us_topic_0181281315_en-us_topic_0170647348_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="making_request__en-us_topic_0181281315_en-us_topic_0170647348_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="making_request__en-us_topic_0181281315_en-us_topic_0170647348_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="making_request__en-us_topic_0181281315_en-us_topic_0170647348_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="making_request__en-us_topic_0181281315_en-us_topic_0170647348_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="making_request__en-us_topic_0181281315_en-us_topic_0170647348_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="making_request__en-us_topic_0181281315_en-us_topic_0170647348_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="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_en-us_topic_0113746487_p17831173918394">Requests the server to update partial content of a specified resource.</p>
<p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_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="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_p3759142614815">For example, in the URI of the IAM API used to obtain a user token, the request method is POST. The request is as follows:</p>
<pre class="screen" id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_screen7888377244">POST https://{{IAM endpoint}}/v3/auth/tokens</pre>
</div>
<div class="section" id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_section479119143310"><h4 class="sectiontitle">Request Header</h4><p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_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 the authentication information, add <span class="parmname" id="making_request__en-us_topic_0181281315_parmname24571922145114"><b>Content-Type</b></span>, which specifies the request body type.</p>
<div class="p" id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_p56967114331"><a href="#making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_table1986821153312">Table 3</a> lists common request header fields.
<div class="tablenoborder"><a name="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_table1986821153312"></a><a name="en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_table1986821153312"></a><table cellpadding="4" cellspacing="0" summary="" id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_table1986821153312" frame="border" border="1" rules="all"><caption><b>Table 3 </b>Common request header fields</caption><thead align="left"><tr id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_row1286841153311"><th align="left" class="cellrowborder" valign="top" width="13.88%" id="mcps1.3.4.3.2.2.5.1.1"><p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_p178680183310"><strong id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_en-us_topic_0113746487_b1355613001117">Field</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="36.08%" id="mcps1.3.4.3.2.2.5.1.2"><p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_p78688118335"><strong id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_en-us_topic_0113746487_b612662015512">Description</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="25.259999999999998%" id="mcps1.3.4.3.2.2.5.1.3"><p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_p58686123316"><strong id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_en-us_topic_0113746487_b812872012519">Mandatory</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="24.779999999999998%" id="mcps1.3.4.3.2.2.5.1.4"><p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_p48681314333"><strong id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_en-us_topic_0113746487_b812932085119">Example</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_row386818143313"><td class="cellrowborder" valign="top" width="13.88%" headers="mcps1.3.4.3.2.2.5.1.1 "><p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_p118689123320">Content-Type</p>
</td>
<td class="cellrowborder" valign="top" width="36.08%" headers="mcps1.3.4.3.2.2.5.1.2 "><p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_p1486815116337">Request body type or format. Its default value is <span class="parmvalue" id="making_request__parmvalue108912521353"><b>application/json</b></span>.</p>
</td>
<td class="cellrowborder" valign="top" width="25.259999999999998%" headers="mcps1.3.4.3.2.2.5.1.3 "><p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_p1086812114335">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="24.779999999999998%" headers="mcps1.3.4.3.2.2.5.1.4 "><p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_p1186841163310">application/json</p>
</td>
</tr>
<tr id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_row11868419337"><td class="cellrowborder" valign="top" width="13.88%" headers="mcps1.3.4.3.2.2.5.1.1 "><p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_p178687119330">Content-Length</p>
</td>
<td class="cellrowborder" valign="top" width="36.08%" headers="mcps1.3.4.3.2.2.5.1.2 "><p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_p178681813332">Specifies the length of the request body. The unit is byte.</p>
</td>
<td class="cellrowborder" valign="top" width="25.259999999999998%" headers="mcps1.3.4.3.2.2.5.1.3 "><p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_p18687183316">No</p>
</td>
<td class="cellrowborder" valign="top" width="24.779999999999998%" headers="mcps1.3.4.3.2.2.5.1.4 "><p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_p148689110334">3495</p>
</td>
</tr>
<tr id="making_request__row1732253992112"><td class="cellrowborder" valign="top" width="13.88%" headers="mcps1.3.4.3.2.2.5.1.1 "><p id="making_request__en-us_topic_0181281315_p229714328223">X-Language</p>
</td>
<td class="cellrowborder" valign="top" width="36.08%" headers="mcps1.3.4.3.2.2.5.1.2 "><p id="making_request__en-us_topic_0181281315_p1529873218222">Specifies the request language.</p>
</td>
<td class="cellrowborder" valign="top" width="25.259999999999998%" headers="mcps1.3.4.3.2.2.5.1.3 "><p id="making_request__en-us_topic_0181281315_p8298133212224">No</p>
</td>
<td class="cellrowborder" valign="top" width="24.779999999999998%" headers="mcps1.3.4.3.2.2.5.1.4 "><p id="making_request__en-us_topic_0181281315_p20298432152214">en_us</p>
</td>
</tr>
<tr id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_row2868171143313"><td class="cellrowborder" valign="top" width="13.88%" headers="mcps1.3.4.3.2.2.5.1.1 "><p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_p586815118338">X-Project-Id</p>
</td>
<td class="cellrowborder" valign="top" width="36.08%" headers="mcps1.3.4.3.2.2.5.1.2 "><p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_p1586811163312">Specifies a project ID. Obtain the project ID by following the instructions in <a href="projectid_accountid.html">Project ID and Account ID</a>.</p>
</td>
<td class="cellrowborder" valign="top" width="25.259999999999998%" headers="mcps1.3.4.3.2.2.5.1.3 "><p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_p886812110335">No</p>
</td>
<td class="cellrowborder" valign="top" width="24.779999999999998%" headers="mcps1.3.4.3.2.2.5.1.4 "><p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_p198684143315">e9993fc787d94b6c886cbaa340f9c0f4</p>
</td>
</tr>
<tr id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_row188688113337"><td class="cellrowborder" valign="top" width="13.88%" headers="mcps1.3.4.3.2.2.5.1.1 "><p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_p198684111335">X-Auth-Token</p>
</td>
<td class="cellrowborder" valign="top" width="36.08%" headers="mcps1.3.4.3.2.2.5.1.2 "><p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_p1086851153317">Specifies a user token.</p>
<p id="making_request__p4825143942914">The user token is a response to the API used to obtain a user token. This API is the only one that does not require authentication.</p>
<p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_p1057635831">The token is the value of <strong id="making_request__b18846637144615">X-Subject-Token</strong> in the response header.</p>
</td>
<td class="cellrowborder" valign="top" width="25.259999999999998%" headers="mcps1.3.4.3.2.2.5.1.3 "><p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_p4868514338">This field is mandatory for token authentication.</p>
</td>
<td class="cellrowborder" valign="top" width="24.779999999999998%" headers="mcps1.3.4.3.2.2.5.1.4 "><p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_p27152505302">The following is part of an example token:</p>
<p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_p168689113318">MIIPAgYJKoZIhvcNAQcCo...ggg1BBIINPXsidG9rZ</p>
</td>
</tr>
<tr id="making_request__row412429192816"><td class="cellrowborder" valign="top" width="13.88%" headers="mcps1.3.4.3.2.2.5.1.1 "><p id="making_request__p10782mcpsimp">X-Sdk-Date</p>
</td>
<td class="cellrowborder" valign="top" width="36.08%" headers="mcps1.3.4.3.2.2.5.1.2 "><p id="making_request__p10784mcpsimp">Time when the request is sent. The time is in <strong id="making_request__b12592411246">YYYYMMDD'T'HHMMSS'Z'</strong> format.</p>
<p id="making_request__p10785mcpsimp">The value is the current GMT time of the system.</p>
</td>
<td class="cellrowborder" valign="top" width="25.259999999999998%" headers="mcps1.3.4.3.2.2.5.1.3 "><p id="making_request__p10787mcpsimp">This field is mandatory for AK/SK-based authentication.</p>
</td>
<td class="cellrowborder" valign="top" width="24.779999999999998%" headers="mcps1.3.4.3.2.2.5.1.4 "><p id="making_request__p10789mcpsimp">20150907T101459Z</p>
</td>
</tr>
<tr id="making_request__en-us_topic_0181281315_row92971324228"><td class="cellrowborder" valign="top" width="13.88%" headers="mcps1.3.4.3.2.2.5.1.1 "><p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_p2086813163316">Host</p>
</td>
<td class="cellrowborder" valign="top" width="36.08%" headers="mcps1.3.4.3.2.2.5.1.2 "><p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_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="making_request__en-us_topic_0171007788_en-us_topic_0121682347_i1012185414574">hostname[:port]</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="25.259999999999998%" headers="mcps1.3.4.3.2.2.5.1.3 "><p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_p886815123319">This field is mandatory for AK/SK-based authentication.</p>
</td>
<td class="cellrowborder" valign="top" width="24.779999999999998%" headers="mcps1.3.4.3.2.2.5.1.4 "><p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_p486814118330">code.test.com</p>
<p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_p5868161163317">or</p>
<p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_p786841123315">code.test.com:443</p>
</td>
</tr>
<tr id="making_request__row1394612515242"><td class="cellrowborder" valign="top" width="13.88%" headers="mcps1.3.4.3.2.2.5.1.1 "><p id="making_request__p10792mcpsimp">Authorization</p>
</td>
<td class="cellrowborder" valign="top" width="36.08%" headers="mcps1.3.4.3.2.2.5.1.2 "><p id="making_request__p10794mcpsimp">Authentication information.</p>
<p id="making_request__p10795mcpsimp">The value can be obtained from the request signing result.</p>
</td>
<td class="cellrowborder" valign="top" width="25.259999999999998%" headers="mcps1.3.4.3.2.2.5.1.3 "><p id="making_request__p10799mcpsimp">This field is mandatory for AK/SK-based authentication.</p>
</td>
<td class="cellrowborder" valign="top" width="24.779999999999998%" headers="mcps1.3.4.3.2.2.5.1.4 "><p id="making_request__p10801mcpsimp">-</p>
</td>
</tr>
<tr id="making_request__row10534534112310"><td class="cellrowborder" valign="top" width="13.88%" headers="mcps1.3.4.3.2.2.5.1.1 "><p id="making_request__en-us_topic_0181281363_p1150183116205">workspace</p>
</td>
<td class="cellrowborder" valign="top" width="36.08%" headers="mcps1.3.4.3.2.2.5.1.2 "><p id="making_request__en-us_topic_0181281363_p169341251122511">Workspace ID. For details about how to obtain it, see <a href="dataartsstudio_02_0350.html">DataArts Studio Instance ID and Workspace ID</a>.</p>
</td>
<td class="cellrowborder" valign="top" width="25.259999999999998%" headers="mcps1.3.4.3.2.2.5.1.3 "><ul id="making_request__ul1960555713242"><li id="making_request__li1860516570243">You do not need to set this field when calling a CDM API because in that case, only the default workspace can be used.</li><li id="making_request__li115375842915">This field is mandatory when there are multiple DataArts Studio instances during a call to a data development API.<p id="making_request__p13534195819299"><a name="making_request__li115375842915"></a><a name="li115375842915"></a>This field is optional when there is only one DataArts Studio instance. If this field is not specified, data in the default workspace is queried by default. To query data in other workspaces, include this field in the request header.</p>
</li></ul>
</td>
<td class="cellrowborder" valign="top" width="24.779999999999998%" headers="mcps1.3.4.3.2.2.5.1.4 "><p id="making_request__p10859mcpsimp">d1cd7861478748a6925bc02f47c69279</p>
</td>
</tr>
<tr id="making_request__row8351550141410"><td class="cellrowborder" valign="top" width="13.88%" headers="mcps1.3.4.3.2.2.5.1.1 "><p id="making_request__p10862mcpsimp">X-Dlm-Type</p>
</td>
<td class="cellrowborder" valign="top" width="36.08%" headers="mcps1.3.4.3.2.2.5.1.2 "><p id="making_request__p10864mcpsimp">DataArts DataService edition, which is Exclusive</p>
</td>
<td class="cellrowborder" valign="top" width="25.259999999999998%" headers="mcps1.3.4.3.2.2.5.1.3 "><p id="making_request__p10866mcpsimp">This parameter is mandatory for calling DataArts DataService APIs.</p>
</td>
<td class="cellrowborder" valign="top" width="24.779999999999998%" headers="mcps1.3.4.3.2.2.5.1.4 "><p id="making_request__p10869mcpsimp"><strong id="making_request__b16981513193813">EXCLUSIVE</strong>: exclusive edition</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="note" id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_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="making_request__en-us_topic_0181281315_en-us_topic_0170647348_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="making_request__b164225294416">Authorization</strong> (signature authentication) and <strong id="making_request__b1842715296418">X-Sdk-Date</strong> (time when the request is sent) header fields are automatically added to the request.</p>
<p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_p1577123365010">For more information, see "AK/SK-based Authentication" in <a href="dataartsstudio_02_0010.html">Authentication</a>.</p>
</div></div>
<p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_p42118461957">The API used to obtain a user token does not require authentication. Therefore, only the <strong id="making_request__b18365115512199">Content-Type</strong> field needs to be added to requests for calling the API. An example of such requests is as follows:</p>
<pre class="screen" id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_screen73731462616">POST https://{{endpoint}}/v3/auth/tokens
Content-Type: application/json</pre>
</div>
<div class="section" id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_en-us_topic_0113746487_section1437471411"><h4 class="sectiontitle">Request Body</h4><p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_en-us_topic_0113746487_p76011911717">The body of a request is often sent in a structured format as specified in the <strong id="making_request__b1729494017523">Content-Type</strong> header field. The request body transfers content except the request header.</p>
<p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_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 <strong id="making_request__b49881446154514">GET</strong> and <strong id="making_request__b13242154920451">DELETE</strong> methods.</p>
<p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_p105261225101112">In the case of the API used to obtain a user token, 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="making_request__i15807155794316">username</em>, <em id="making_request__i1180755724315">domainname</em>, <em id="making_request__i11808185764316">********</em> (login password), and <em id="making_request__i16808457104311">xxxxxxxxxxxxxxxxxx</em> (project ID) with the actual values. To learn how to obtain a project ID, see <a href="projectid_accountid.html">Project ID and Account ID</a>.</p>
<div class="note" id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_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="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_p199011223194814">The <strong id="making_request__en-us_topic_0181281315_b13561343133716">scope</strong> parameter specifies where a token takes effect. You can set <strong id="making_request__b1016372014917">scope</strong> to an account or a project under an account..</p>
</div></div>
<pre class="screen" id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_en-us_topic_0121682347_screen6140617194816">
POST https://{{endpoint}}/v3/auth/tokens
Content-Type: application/json
{
"auth": {
"identity": {
"methods": [
"password"
],
"password": {
"user": {
"name": "<em id="making_request__i15558303510"><strong id="making_request__b459517153520">username</strong></em>",
"password": "<em id="making_request__i108086613352"><strong id="making_request__b92314653516">********</strong></em>",
"domain": {
"name": "<em id="making_request__i20729121733512"><strong id="making_request__b11201117183511">domainname</strong></em>"
}
}
}
},
"scope": {
"project": {
"id": "<em id="making_request__i111262693516"><strong id="making_request__b4720725183512">xxxxxxxxxxxxxxxxxx</strong></em>"
}
}
}
}</pre>
<p id="making_request__en-us_topic_0181281315_en-us_topic_0170647348_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. For the API used to obtain a user token, <strong id="making_request__b151691739142620">x-subject-token</strong> in the response header 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="dataartsstudio_02_0008.html">Calling APIs</a></div>
</div>
</div>