doc-exports/docs/vpn/api-ref/vpn_api_0011.html
Hongwei, King Wang 32c06a10a2 vpn_api
Reviewed-by: Sarda, Priya <prsarda@noreply.gitea.eco.tsi-dev.otc-service.com>
Co-authored-by: Hongwei, King Wang <king.wanghongwei@huawei.com>
Co-committed-by: Hongwei, King Wang <king.wanghongwei@huawei.com>
2024-08-15 14:18:28 +00:00

62 lines
6.8 KiB
HTML

<a name="EN-US_TOPIC_0000001854089177"></a><a name="EN-US_TOPIC_0000001854089177"></a>
<h1 class="topictitle1">Response</h1>
<div id="body8662426"><p id="EN-US_TOPIC_0000001854089177__en-us_topic_0000001543673232_p56381426296"><strong id="EN-US_TOPIC_0000001854089177__en-us_topic_0000001543673232_b263872112913">Status Code</strong></p>
<p id="EN-US_TOPIC_0000001854089177__en-us_topic_0000001543673232_p1463842162920">After sending a request, you can receive a response, including a status code, response header, and response body.</p>
<p id="EN-US_TOPIC_0000001854089177__en-us_topic_0000001543673232_p16389262913">A status code is a group of digits, ranging from 1xx to 5xx. It indicates the status of a response. For more information, see <a href="vpn_api_0052.html#EN-US_TOPIC_0000001807370508">Status Codes</a>.</p>
<p id="EN-US_TOPIC_0000001854089177__en-us_topic_0000001543673232_p176380272911">For example, if status code <strong id="EN-US_TOPIC_0000001854089177__en-us_topic_0000001543673232_b573918414020">201</strong> is returned after you call the API for obtaining a user token, the request is successful.</p>
<p id="EN-US_TOPIC_0000001854089177__en-us_topic_0000001543673232_p96384217292"><strong id="EN-US_TOPIC_0000001854089177__en-us_topic_0000001543673232_b563819292915">Response Header</strong></p>
<p id="EN-US_TOPIC_0000001854089177__en-us_topic_0000001543673232_p1263814216291">Like a request, a response also has a header, for example, <strong id="EN-US_TOPIC_0000001854089177__en-us_topic_0000001543673232_b768715852313">Content-Type</strong>.</p>
<p id="EN-US_TOPIC_0000001854089177__en-us_topic_0000001543673232_p663820202917"><a href="#EN-US_TOPIC_0000001854089177__en-us_topic_0000001543673232_fig10238149134019">Figure 1</a> shows the response header for the API used to obtain a user token. The <strong id="EN-US_TOPIC_0000001854089177__en-us_topic_0000001543673232_b922211013015">x-subject-token</strong> field carries a user token. You can use this token to authenticate the calling of other APIs.</p>
<div class="fignone" id="EN-US_TOPIC_0000001854089177__en-us_topic_0000001543673232_fig10238149134019"><a name="EN-US_TOPIC_0000001854089177__en-us_topic_0000001543673232_fig10238149134019"></a><a name="en-us_topic_0000001543673232_fig10238149134019"></a><span class="figcap"><b>Figure 1 </b>Response header for the API used to obtain a user token</span><br><span><img id="EN-US_TOPIC_0000001854089177__en-us_topic_0000001543673232_image8840548519" src="figure/en-us_image_0000001594578277.png" title="Click to enlarge" class="imgResize"></span></div>
<p id="EN-US_TOPIC_0000001854089177__en-us_topic_0000001543673232_p20697174513305"><strong id="EN-US_TOPIC_0000001854089177__en-us_topic_0000001543673232_b1024841323716">Response Body</strong></p>
<p id="EN-US_TOPIC_0000001854089177__en-us_topic_0000001543673232_p269794514306">This part is optional. A response body is generally returned in a structured format (for example, JSON or XML), which is specified by <strong id="EN-US_TOPIC_0000001854089177__en-us_topic_0000001543673232_b01771811153918">Content-Type</strong> in the response header. It is used to transfer content other than the response header.</p>
<p id="EN-US_TOPIC_0000001854089177__en-us_topic_0000001543673232_p1269712454305">The following is part of a response body for the API used to obtain a user token.</p>
<div class="codecoloring" codetype="Json" id="EN-US_TOPIC_0000001854089177__en-us_topic_0000001543673232_screen71528815314"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal"> 1</span>
<span class="normal"> 2</span>
<span class="normal"> 3</span>
<span class="normal"> 4</span>
<span class="normal"> 5</span>
<span class="normal"> 6</span>
<span class="normal"> 7</span>
<span class="normal"> 8</span>
<span class="normal"> 9</span>
<span class="normal">10</span>
<span class="normal">11</span></pre></div></td><td class="code"><div><pre><span></span><span class="p">{</span>
<span class="w"> </span><span class="nt">&quot;token&quot;</span><span class="p">:</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="nt">&quot;expires_at&quot;</span><span class="p">:</span><span class="w"> </span><span class="s2">&quot;2022-09-10T06:52:13.855000Z&quot;</span><span class="p">,</span>
<span class="w"> </span><span class="nt">&quot;methods&quot;</span><span class="p">:</span><span class="w"> </span><span class="p">[</span>
<span class="w"> </span><span class="s2">&quot;password&quot;</span>
<span class="w"> </span><span class="p">],</span>
<span class="w"> </span><span class="nt">&quot;catalog&quot;</span><span class="p">:</span><span class="w"> </span><span class="p">[</span>
<span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="nt">&quot;endpoints&quot;</span><span class="p">:</span><span class="w"> </span><span class="p">[</span>
<span class="w"> </span><span class="p">{</span>
<span class="err">......</span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001854089177__en-us_topic_0000001543673232_p6471132310">If an error occurs during API calling, an error code and an error message will be displayed. The following is an example of an error response body.</p>
<div class="codecoloring" codetype="Json" id="EN-US_TOPIC_0000001854089177__en-us_topic_0000001543673232_screen1321510482317"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
<span class="normal">2</span>
<span class="normal">3</span>
<span class="normal">4</span></pre></div></td><td class="code"><div><pre><span></span><span class="p">{</span>
<span class="w"> </span><span class="nt">&quot;error_msg&quot;</span><span class="p">:</span><span class="w"> </span><span class="s2">&quot;The format of message is error&quot;</span><span class="p">,</span>
<span class="w"> </span><span class="nt">&quot;error_code&quot;</span><span class="p">:</span><span class="w"> </span><span class="s2">&quot;AS.0001&quot;</span>
<span class="p">}</span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001854089177__en-us_topic_0000001543673232_p178031137310"><strong id="EN-US_TOPIC_0000001854089177__en-us_topic_0000001543673232_b098819485452">error_code</strong> specifies an error code, and <strong id="EN-US_TOPIC_0000001854089177__en-us_topic_0000001543673232_b1298964813453">error_msg</strong> describes the error.</p>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="vpn_api_0008.html">Calling APIs</a></div>
</div>
</div>
<script language="JavaScript">
<!--
image_size('.imgResize');
var msg_imageMax = "view original image";
var msg_imageClose = "close";
//--></script>