doc-exports/docs/ocr/umn/ocr_01_0153.html
Sheng, Lichang 86871abfe4 OCR usermanual 20240111 v2
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com>
Co-authored-by: Sheng, Lichang <lichangsheng1@noreply.gitea.eco.tsi-dev.otc-service.com>
Co-committed-by: Sheng, Lichang <lichangsheng1@noreply.gitea.eco.tsi-dev.otc-service.com>
2024-01-17 10:42:31 +00:00

76 lines
12 KiB
HTML

<a name="ocr_01_0153"></a><a name="ocr_01_0153"></a>
<h1 class="topictitle1">Getting Started</h1>
<div id="body0000001704118414"><p id="ocr_01_0153__p12763143822111">Use Postman to call the General Text OCR API.</p>
<p id="ocr_01_0153__p1298711255535">To call an OCR API, perform the following steps:</p>
<p id="ocr_01_0153__p3394175015315"><a href="#ocr_01_0153__section1471165201415">Step 1: Subscribing to a Service</a></p>
<p id="ocr_01_0153__p1441321118"><a href="#ocr_01_0153__section169054167464">Step 2: Configuring the Environment</a></p>
<p id="ocr_01_0153__p89181638172212"><a href="#ocr_01_0153__section92251373345">Step 3: Using a Token for Authentication</a></p>
<p id="ocr_01_0153__p91691491810"><a href="#ocr_01_0153__section26131714406">Step 4: Calling the Service</a></p>
<div class="section" id="ocr_01_0153__section1471165201415"><a name="ocr_01_0153__section1471165201415"></a><a name="section1471165201415"></a><h4 class="sectiontitle">Step 1: Subscribing to a Service</h4><ol id="ocr_01_0153__ol168583537176"><li id="ocr_01_0153__li1185819538178">Log in to the OCR management console.<p id="ocr_01_0153__p1880721511339"><a name="ocr_01_0153__li1185819538178"></a><a name="li1185819538178"></a>Select a region based on service requirements. For details about the region where each service is deployed, see <a href="https://docs.otc.t-systems.com/additional/endpoints.html" target="_blank" rel="noopener noreferrer">Regions and Endpoints</a>.</p>
</li><li id="ocr_01_0153__li107813841214">On the page displayed, select and subscribe to your desired APIs.<p id="ocr_01_0153__p1633017350389"><a name="ocr_01_0153__li107813841214"></a><a name="li107813841214"></a>For this example, subscribe to the General Text OCR API.</p>
</li></ol>
</div>
<div class="section" id="ocr_01_0153__section169054167464"><a name="ocr_01_0153__section169054167464"></a><a name="section169054167464"></a><h4 class="sectiontitle">Step 2: Configuring the Environment</h4><p id="ocr_01_0153__p45707591326">Download and install <a href="https://www.postman.com/downloads/" target="_blank" rel="noopener noreferrer">Postman</a>.</p>
</div>
<div class="section" id="ocr_01_0153__section92251373345"><a name="ocr_01_0153__section92251373345"></a><a name="section92251373345"></a><h4 class="sectiontitle">Step 3: Using a Token for Authentication</h4><p id="ocr_01_0153__p244821310212">Tokens are used for identity authentication and permission management when calling an OCR API.</p>
<p id="ocr_01_0153__p4614595913">Before calling an OCR API, you need first use the "Obtaining a Token" API to obtain the token value. Then, pass the token value into the request header parameter of the OCR API to authenticate the user's API request and enable the OCR service to verify their identity.</p>
<div class="note" id="ocr_01_0153__note187231041191017"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="ocr_01_0153__p11723164118107">The token is valid for 24 hours.</p>
</div></div>
<p id="ocr_01_0153__p12581722162614">To obtain the token, perform the following steps:</p>
<ol id="ocr_01_0153__ol17372193632613"><li id="ocr_01_0153__li0372173615268">Log in to the cloud, hover your cursor over the username in the upper right corner, and choose <strong id="ocr_01_0153__b75951281267">My Credentials</strong>. On the <strong id="ocr_01_0153__b0205175917714">API Credentials</strong> page displayed, obtain the username, domain name, and project ID.<p id="ocr_01_0153__p16612161852810"></p>
<div class="fignone" id="ocr_01_0153__fig6814049131116"><span class="figcap"><b>Figure 1 </b>Obtaining the username, domain name, and project ID</span><br><span><img id="ocr_01_0153__image981413497115" src="en-us_image_0000001707122028.png" height="109.066118" width="465.5" title="Click to enlarge" class="imgResize"></span></div>
</li><li id="ocr_01_0153__li156951408285">Start Postman and create a POST request. For example, to obtain a token in the <strong id="ocr_01_0153__b1621211287114">eu-de</strong> region, enter the following URL and request header parameter:<ul id="ocr_01_0153__ul9708173317550"><li id="ocr_01_0153__li187085330554">URL: <strong id="ocr_01_0153__b19539135641119">https://iam.eu-de.otc.t-systems.com/v3/auth/tokens</strong></li><li id="ocr_01_0153__li16708193395512">Request header parameter: <strong id="ocr_01_0153__b1739034919129">Content-Type</strong>; parameter value: <strong id="ocr_01_0153__b1024210681313">application/json</strong></li></ul>
<div class="fignone" id="ocr_01_0153__fig14230701316"><span class="figcap"><b>Figure 2 </b>Entering the URL and request header parameter</span><br><span><img id="ocr_01_0153__image123012018117" src="en-us_image_0000001755213865.png" height="114.371887" width="465.5" title="Click to enlarge" class="imgResize"></span></div>
</li><li id="ocr_01_0153__li1818162919503">Enter the request body of the API for obtaining a token. Click <strong id="ocr_01_0153__b129141548121613">Body</strong>, select <strong id="ocr_01_0153__b9131052171614">raw</strong>, copy and enter the following code by referring to <a href="#ocr_01_0153__fig127711342268">Figure 3</a>, and enter the username, domain name, and password.<pre class="screen" id="ocr_01_0153__screen12126163710119">{
"auth": {
"identity": {
"methods": [
"password"
],
"password": {
"user": {
"name": "<strong id="ocr_01_0153__b6382144419114"><em id="ocr_01_0153__i1338219441014">username</em></strong>", // IAM username
"password": "<strong id="ocr_01_0153__b173827441315"><em id="ocr_01_0153__i93827441615">********</em></strong>", // User password
"domain": {
"name": "<strong id="ocr_01_0153__b1738211442110"><em id="ocr_01_0153__i193829441314">domainname</em></strong>" // Domain name
}
}
}
},
<strong id="ocr_01_0153__b738212442018"> </strong>"scope": {
<strong id="ocr_01_0153__b1338213440116"> </strong>"project": {<strong id="ocr_01_0153__b1138212444118"> </strong>
<strong id="ocr_01_0153__b2382344918"> </strong> "name": "eu-de"
<strong id="ocr_01_0153__b1382144412114"> </strong>}
<strong id="ocr_01_0153__b143828441618"> </strong>}
}
}</pre>
<div class="fignone" id="ocr_01_0153__fig127711342268"><a name="ocr_01_0153__fig127711342268"></a><a name="fig127711342268"></a><span class="figcap"><b>Figure 3 </b>Request body</span><br><span><img id="ocr_01_0153__image187712424614" src="en-us_image_0000001755220149.png" height="241.55872300000001" width="465.5" title="Click to enlarge" class="imgResize"></span></div>
</li><li id="ocr_01_0153__li128498845718">Click <strong id="ocr_01_0153__b13491230993824">Send</strong> to send the request. If the status code <strong id="ocr_01_0153__b67191515215">201</strong> is returned, the API is successfully called. In this case, click <strong id="ocr_01_0153__b765112557249">Headers</strong>, find and copy the <strong id="ocr_01_0153__b1112018532514">X-Subject-Token</strong> value, which is the token.<div class="fignone" id="ocr_01_0153__fig173861228114918"><a name="ocr_01_0153__fig173861228114918"></a><a name="fig173861228114918"></a><span class="figcap"><b>Figure 4 </b>Obtaining a token</span><br><span><img id="ocr_01_0153__image14386132834914" src="en-us_image_0000001707404882.png" height="189.738199" width="465.5" title="Click to enlarge" class="imgResize"></span></div>
</li></ol>
</div>
<div class="section" id="ocr_01_0153__section26131714406"><a name="ocr_01_0153__section26131714406"></a><a name="section26131714406"></a><h4 class="sectiontitle">Step 4: Calling the Service</h4><ol id="ocr_01_0153__ol6493854191612"><li id="ocr_01_0153__li10493135451615">Create a POST request in Postman and enter the API request address. For details, see "APIs" in <em id="ocr_01_0153__i1957194825918">Optical Character Recognition API Reference</em>.<p id="ocr_01_0153__p1110205616185">Example: <strong id="ocr_01_0153__b5168184515284">https://ocr.eu-de.otc.t-systems.com/v2/{project_id}/ocr/general-text</strong></p>
</li><li id="ocr_01_0153__li14327195821617">Set two request header parameters by referring to <a href="#ocr_01_0153__fig14631357133312">Figure 5</a>.<ul id="ocr_01_0153__ul33891324121911"><li id="ocr_01_0153__li11389172491920"><strong id="ocr_01_0153__b8933181912589">KEY</strong>: <strong id="ocr_01_0153__b21813910296">Content-Type</strong>; <strong id="ocr_01_0153__b185271125195815">VALUE</strong>: <strong id="ocr_01_0153__b518212913295">application/json</strong></li><li id="ocr_01_0153__li10733129171910"><strong id="ocr_01_0153__b4571933175814">KEY</strong>: <strong id="ocr_01_0153__b1330114712291">X-Auth-Token</strong>; <strong id="ocr_01_0153__b1169133717585">VALUE</strong>: the token value obtained in <a href="#ocr_01_0153__fig173861228114918">Figure 4</a><div class="fignone" id="ocr_01_0153__fig14631357133312"><a name="ocr_01_0153__fig14631357133312"></a><a name="fig14631357133312"></a><span class="figcap"><b>Figure 5 </b>Request header</span><br><span><img id="ocr_01_0153__image963235763312" src="en-us_image_0000001707228246.png" height="148.6275" width="465.5" title="Click to enlarge" class="imgResize"></span></div>
</li></ul>
</li><li id="ocr_01_0153__li4316194621813">Click <strong id="ocr_01_0153__b95793218344">Body</strong>, select <strong id="ocr_01_0153__b758072183411">raw</strong>, copy and enter the following code by referring to <a href="#ocr_01_0153__fig0629142183912">Figure 6</a>, and enter the request body.<pre class="screen" id="ocr_01_0153__screen108523195379">{
"image":"/9j/4AAQSkZJRgABAgEASABIAAD/4RFZRXhpZgAATU0AKgAAAA...",
"detect_direction":false,
"quick_mode":false
}</pre>
<div class="fignone" id="ocr_01_0153__fig0629142183912"><a name="ocr_01_0153__fig0629142183912"></a><a name="fig0629142183912"></a><span class="figcap"><b>Figure 6 </b>Request body</span><br><span><img id="ocr_01_0153__image06301521398" src="en-us_image_0000001707396210.png" height="115.25926300000002" width="465.5" title="Click to enlarge" class="imgResize"></span></div>
</li><li id="ocr_01_0153__li98622226243">Click <strong id="ocr_01_0153__b126214175917">Send</strong> to send the request. If the status code <strong id="ocr_01_0153__b430212139352">200</strong> is returned, the API is successfully called and you can view the returned information in Postman.<div class="fignone" id="ocr_01_0153__fig4391951145912"><span class="figcap"><b>Figure 7 </b>Obtaining the calling result</span><br><span><img id="ocr_01_0153__image15398514596" src="en-us_image_0000001707409654.png" height="179.997678" width="465.5" title="Click to enlarge" class="imgResize"></span></div>
</li></ol>
<div class="p" id="ocr_01_0153__p0888147452"><div class="note" id="ocr_01_0153__note19993175733316"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="ocr_01_0153__ul1729623517319"><li id="ocr_01_0153__li4296193543120">If you encounter an error message in Postman while calling APIs that indicates an invalid SSL certificate, such as <strong id="ocr_01_0153__b7585195610426">self signed certificate</strong>, <strong id="ocr_01_0153__b61361111431">certificate has expired</strong>, or <strong id="ocr_01_0153__b15792152812437">unable to verify the first certificate</strong>, you can resolve the issue by disabling <strong id="ocr_01_0153__b168081957134317">SSL certificate verification</strong> in Postman's settings.</li><li id="ocr_01_0153__li127056391316">For details about the request and response parameters of OCR APIs, see <em id="ocr_01_0153__i69078371307">Optical Character API Reference</em>.</li></ul>
</div></div>
</div>
</div>
</div>
<div></div>
<script language="JavaScript">
<!--
image_size('.imgResize');
var msg_imageMax = "view original image";
var msg_imageClose = "close";
//--></script>