Moderation (Text)
This section provides an example of how to use Postman to call Moderation (Text), helping you quickly get familiar with the service. The procedure is as follows:
Step 1: Subscribing to a Service. In the left navigation pane, choose Service List or Service Management, and subscribe to Text Moderation.
Step 2: Configuring a Custom Dictionary. Configure allowlist and blocklist dictionaries.
Step 3: Configuring the Environment. Import the prepared configuration file into the development environment.
Step 4: Using a Token for Authentication. When you call an API, a token is required for authentication.
Step 5: Calling a Service API. Call the service API. You can view the status code and error code at any time during the usage.
(Optional) Step 6: Viewing the Number of API Calls. View call statistics and call details.
Step 1: Subscribing to a Service
To subscribe to a service, perform the following steps:
- Log in to HUAWEI CLOUD, apply for a HUAWEI CLOUD account, and complete real-name authentication.
- On the top of the HUAWEI CLOUD page, choose .
- On the product page, click Try Now and enter the username and password to access the Content Moderation management console.
- Subscribe to your desired service on the Service List or Service Management page. For example, to subscribe to Text Moderation on the Service Management page, select Text Moderation in Commercial Services and click Subscribe.
You only need to subscribe to the service once.
- After a commercial service is successfully subscribed, the service is displayed in My Services on the Service Management page. In this case, you can call the API to use Moderation (Text).
Step 2: Configuring a Custom Dictionary
You can configure allowlist and blocklist dictionaries for text moderation.
- If an allowlist dictionary is customized, the words in the allowlist dictionary will not be detected when you use text moderation.
- Log in to the HUAWEI CLOUD and click Console in the upper right corner. The Console page is displayed.
- Click Service List, and choose EI Enterprise Intelligence > Content Moderation. The Content Moderation management console is displayed.
- In the left navigation pane, choose Service List > Text Moderation. Click Configuration next to Custom Allowlist Dictionary. The Create Dictionary dialog box is displayed. Figure 1 Create Dictionary
- Enter a dictionary name and the keywords in the allowlist dictionary. Click OK.
- Dictionary Name: A dictionary name contains a maximum of 40 characters. Only letters, digits, hyphens (-), and underscores (_) are allowed.
- Add Keyword: A dictionary contains a maximum of 5000 keywords. Each keyword consists of a maximum of 40 characters and ends with a carriage return.
- If a blocklist dictionary is customized, the words in the blocklist dictionary will be detected when you use text moderation.
- Log in to the HUAWEI CLOUD and click Console in the upper right corner. The Console page is displayed.
- Click Service List, and choose EI Enterprise Intelligence > Content Moderation. The Content Moderation management console is displayed.
- In the left navigation pane, choose Service List > Text Moderation. Click Configuration next to Custom Blocklist Dictionary. The Custom Dictionary page is displayed.
- Click Create Dictionary in the upper left corner. The Create Dictionary dialog box is displayed. Enter a dictionary name and the keywords in the blocklist dictionary.
- Dictionary Name: A dictionary name contains a maximum of 40 characters. Only letters, digits, hyphens (-), and underscores (_) are allowed.
- Add Keyword: A dictionary contains a maximum of 5000 keywords. Each keyword consists of a maximum of 40 characters and ends with a carriage return.
- Click OK.
- The dictionary name cannot be modified.
Step 3: Configuring the Environment
- Download and install Postman.
- Download the Postman configuration file for Content Moderation.
- Import the configuration file.
- Open and log in to Postman.
- Choose File > Import in the upper left corner. In the displayed dialog, click Upload Files to import the configuration file. Figure 2 Importing the configuration file
- After the configuration file is imported, it is displayed in the Collections directory in the left navigation pane. Figure 3 Configuration Files
Step 4: Using a Token for Authentication
A token is a user's access credential, which includes user identities and permissions. When you call an API to access a cloud service, a token is required for identity authentication.
- In the Collections directory in the navigation pane of Postman, click the get-token configuration file.
- Click Body. Enter the username, password, and domain name.
To obtain the username, password, and domain name, perform the following steps:
- Log in to the management console.
- Hover the cursor on the username and choose My Credentials from the drop-down list. Copy the IAM username and account name to username and domainname, and enter the IAM user password.
Figure 4 Token-based authentication
- Click Send to send a request, and obtain and copy the token.
In Headers, obtain the value of X-Subject-Token, which is the token. The token is valid for 24 hours.
Figure 5 Obtaining a token
Step 5: Calling a Service API
- In the Collections directory in the navigation pane of Postman, click the Moderation_image configuration file.
- Click Headers and copy the token value to X-Auth-Token. Figure 6 Entering the token
- Click Body and enter the text to be checked for the text parameter.
- For details about other parameters in the body, see the Text Moderation API. Figure 7 Modifying the parameters
- For details about other parameters in the body, see the Text Moderation API.
- Click Send to send the request and obtain the API call results.
{ "result": { "detail": {}, "suggestion": "pass" } }
(Optional) Step 6: Viewing the Number of API Calls
- View the number of API calls. Choose , and view call statistics and call details. See Figure 8.
- The Call Statistics section provides three statistical charts, displaying daily calls, daily blocked text, and daily reviewed text. You can set a time range to view the change of the number of API calls within the time range.
- The Call Details section lists the total number of calls, blocks, reviews, and passes every day. This helps you better understand service calls and their statuses.
- block indicates that sensitive information is contained and the information is blocked.
- pass indicates that sensitive information is not contained and the information is approved.
- review indicates that manual review is required.
- View monitoring metrics. You can click View Metric to view historical data such as successful and failed calls on the Cloud Eye console. See Figure 9.
Last Article: Using Postman to Call Content Moderation
Next Article: Moderation (Image)


Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.