Getting Started

Use Postman to call the General Text OCR API.

To call an OCR API, perform the following steps:

Step 1: Subscribing to a Service

Step 2: Configuring the Environment

Step 3: Using a Token for Authentication

Step 4: Calling the Service

Step 1: Subscribing to a Service

  1. Log in to the OCR management console.

    Select a region based on service requirements. For details about the region where each service is deployed, see Regions and Endpoints.

  2. On the page displayed, select and subscribe to your desired APIs.

    For this example, subscribe to the General Text OCR API.

Step 2: Configuring the Environment

Download and install Postman.

Step 3: Using a Token for Authentication

Tokens are used for identity authentication and permission management when calling an OCR API.

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.

Note

The token is valid for 24 hours.

To obtain the token, perform the following steps:

  1. Log in to the cloud, hover your cursor over the username in the upper right corner, and choose My Credentials. On the API Credentials page displayed, obtain the username, domain name, and project ID.

    **Figure 1** Obtaining the username, domain name, and project ID

    Figure 1 Obtaining the username, domain name, and project ID

  2. Start Postman and create a POST request. For example, to obtain a token in the eu-de region, enter the following URL and request header parameter:

    • URL: https://iam.eu-de.otc.t-systems.com/v3/auth/tokens

    • Request header parameter: Content-Type; parameter value: application/json

    **Figure 2** Entering the URL and request header parameter

    Figure 2 Entering the URL and request header parameter

  3. Enter the request body of the API for obtaining a token. Click Body, select raw, copy and enter the following code by referring to Figure 3, and enter the username, domain name, and password.

    {
        "auth": {
            "identity": {
                "methods": [
                    "password"
                ],
                "password": {
                    "user": {
                        "name": "username", // IAM username
                        "password": "********", // User password
                        "domain": {
                            "name": "domainname" // Domain name
                        }
                    }
                }
            },
            "scope": {
                "project": {
                    "name": "eu-de"
                }
            }
        }
    }
    
    **Figure 3** Request body

    Figure 3 Request body

  4. Click Send to send the request. If the status code 201 is returned, the API is successfully called. In this case, click Headers, find and copy the X-Subject-Token value, which is the token.

    **Figure 4** Obtaining a token

    Figure 4 Obtaining a token

Step 4: Calling the Service

  1. Create a POST request in Postman and enter the API request address. For details, see "APIs" in Optical Character Recognition API Reference.

    Example: https://ocr.eu-de.otc.t-systems.com/v2/{project_id}/ocr/general-text

  2. Set two request header parameters by referring to Figure 5.

    • KEY: Content-Type; VALUE: application/json

    • KEY: X-Auth-Token; VALUE: the token value obtained in Figure 4

      **Figure 5** Request header

      Figure 5 Request header

  3. Click Body, select raw, copy and enter the following code by referring to Figure 6, and enter the request body.

    {
         "image":"/9j/4AAQSkZJRgABAgEASABIAAD/4RFZRXhpZgAATU0AKgAAAA...",
         "detect_direction":false,
         "quick_mode":false
       }
    
    **Figure 6** Request body

    Figure 6 Request body

  4. Click Send to send the request. If the status code 200 is returned, the API is successfully called and you can view the returned information in Postman.

    **Figure 7** Obtaining the calling result

    Figure 7 Obtaining the calling result

Note

  • If you encounter an error message in Postman while calling APIs that indicates an invalid SSL certificate, such as self signed certificate, certificate has expired, or unable to verify the first certificate, you can resolve the issue by disabling SSL certificate verification in Postman's settings.

  • For details about the request and response parameters of OCR APIs, see Optical Character API Reference.