All Documents
Natural Language ProcessingNatural Language Processing
- what's new
- Service Overview
- Getting Started
- API Reference
-
FAQs
- How Do I Obtain a User Token Using Postman?
- What Should I Do If an NLP API Call Fails?
- Which Methods Can Be Used to Call NLP APIs?
- Must I Subscribe to NLP Before Calling NLP APIs?
- Can NLP Be Deployed on Premises?
- Can I Use NLP Offline?
- What Are Restrictions for Using NLP?
- What Are the Username, Domain Name, and Project Name in the Token Message Body?
- Regions and AZs
- What Permissions Do I Need to Use NLP?
- What Should I Do If I Want to Customize NLP?
- Which Languages Can NLP Process?
- More Documents
How Do I Obtain a User Token Using Postman?
Postman is a visual editing tool for building and testing API requests. It provides an easy-to-use user interface to send HTTP requests, including GET, PUT, POST, and DELETE requests. Postman allows you to modify parameters of HTTP requests and returns response to your requests.
A token is a user's access credential, which includes user identities and permissions. When you call an API to access cloud resources, a token is required for identity authentication.
Perform the procedure described in this section to obtain a user token using Postman. For details about the parameters, see Obtaining a User Token.
Prerequisites
You have installed and registered with Postman.
Procedure
- Edit the request URL, header, and body of the API used to obtain a token for calling APIs.
- Request URLThe request URL is in the format https://IAM region and endpoint/API URI.
- Obtain the IAM region and endpoint from Regions and Endpoints.Currently, NLP Fundamentals, language generation, language understanding, and machine translation APIs are available in the CN North-Beijing4 region.Figure 1 IAM regions and endpoints
- Obtain the API URI from Obtaining a User Token.
For example, the request URL in the ap-southeast-3 region is https://iam.ap-southeast-3.myhwclouds.com/v3/auth/tokens.
- Select an API request method and enter the request URL in Postman.
- Obtain the IAM region and endpoint from Regions and Endpoints.
- Request Header
Set key to Content-Type and value to application/json;charset=utf8.
- Request BodyModify parameters in the example request body.
{ "auth": { "identity": { "methods": [ "password" ], "password": { "user": { "domain": { "name": "Account name" }, "name": "IAM user name", "password": "IAM user password" } } }, "scope": { "domain": { "name": "Account name" } } } }
- For details, see Obtaining Account, IAM User, and Project Information.
If no IAM user is created, use the administrator account to create an IAM user and configure a password for it. For details, see Creating an IAM User.
- Third-party system users can set a password by clicking Forgot Password on the login page.
- For details, see Obtaining Account, IAM User, and Project Information.
- Request URL
- Click Send to send the API request.
- View the token in the response header. When you call other IAM APIs, you can use this token for authentication.
- The validity period of a token is 24 hours. If you want to use a token for authentication, cache it to avoid frequently calling the IAM API.
- If an error code, for example 401, is returned, the authentication fails. Confirm that parameters in the request body are correct and send the request again.
- If "Header Overflow" is displayed, resolve the problem by referring to Solution.
Solution
We have found that Postman of V7.25.0, V7.26.0, or later cannot be used to obtain a user token due to configurations. The message "Header Overflow" will be displayed if you use any of these versions.
- Method 1
Use an earlier version of Postman, such as V5.xx.
- Method 2:
Run the following curl command to obtain a token and replace the text in bold with actual values:
curl -ik -X POST -H 'Content-Type=application/json;charset=utf8' -d '{"auth": {"identity": {"methods": ["password"],"password": {"user": {"domain": {"name": "Account name"},"name": "IAM user name","password": "IAM user password"}},},"scope": {"domain": {"name": "Account name"}}}}' https://iam.ap-southeast-1.myhuaweicloud.com/v3/auth/tokens
- Method 3
Pass an additional environment variable NODE_OPTIONS=--max-http-header-size=16384 (16KB) to Postman to specify the maximum size of the HTTP header (in bytes).
Run one of the following commands depending on your OS:
- macOS
NODE_OPTIONS=--max-http-header-size=16384 /Applications/Postman.app/Contents/MacOS/Postman
- Linux
NODE_OPTIONS=--max-http-header-size=16384 /path/to/Postman/Postman
- Windows
set NODE_OPTIONS=--max-http-header-size=16384 C:\users\<username>\AppData\local\Postman\Postman.exe
- macOS