Common parameters are components included in all API requests. They consist of common request headers and common request parameters.
Common request headers
The following table describes the common request headers for HTTP POST requests to the AI Guardrails API.
|
Parameter |
Type |
Required |
Description |
|
Accept |
String |
Yes |
The accepted response format. The value must be application/json. |
|
Content-Type |
String |
Yes |
The data type of the request body. The value must be application/json. |
|
Content-MD5 |
String |
Conditional |
The Base64-encoded MD5 hash of the request body. Calculation: Compute the MD5 hash of the request body, and then Base64-encode the resulting binary data. Note
This header is required when the signing method is HMAC-SHA1 (default) and optional when the signing method is HMAC-SM3. |
|
Date |
String |
Yes |
The request timestamp in GMT format. For example, |
|
x-acs-version |
String |
Yes |
The version of the AI Guardrails API. The value must be 2018-05-09. Important
API versions prior to 2018-05-09 are discontinued. Requests that use an older version number fail with an |
|
x-acs-signature-nonce |
String |
Yes |
A unique random string (nonce) to prevent replay attacks. Use a different nonce for each request. |
|
x-acs-signature-version |
String |
Yes |
The signature version. The value must be 1.0. |
|
x-acs-signature-method |
String |
Yes |
The signing method. Valid values:
For more information about signing methods, see Request signatures. |
|
x-acs-content-sm3 |
String |
Conditional |
The SM3 hash of the request body, encoded as a hexadecimal string. This header is required when the signing method is HMAC-SM3. Calculation: Compute the SM3 hash of the request body, and then convert the resulting byte array to a hexadecimal string. This is equivalent to |
|
Authorization |
String |
Yes |
The authentication credential, formatted as Parameters:
|
Common request parameters
The following table describes the common request parameters. Include these as a query string in your HTTP POST requests to the AI Guardrails API.
|
Parameter |
Type |
Required |
Description |
|
clientInfo |
String |
No |
Information about the client that initiated the request. This value is a JSON-serialized |
|
Parameter |
Type |
Required |
Description |
|
sdkVersion |
String |
No |
The SDK version. This parameter is required when using an SDK. For more information, see SDK overview. |
|
cfgVersion |
String |
No |
The configuration version. This parameter is required when using an SDK. For more information, see SDK overview. |
|
userType |
String |
No |
The type of user account. Valid values:
|
|
userId |
String |
No |
The unique ID of the user in your business system. We strongly recommend that you specify this parameter for user violation analysis. |
|
userNick |
String |
No |
The user's nickname. |
|
imei |
String |
No |
The International Mobile Equipment Identity (IMEI) of the device. |
|
imsi |
String |
No |
The International Mobile Subscriber Identity (IMSI) of the device. |
|
umid |
String |
No |
The unique machine identifier (UMID) of the device. |
|
ip |
String |
No |
The public IP address of the user who initiated the request. If a request originates from a client device, you can typically omit this parameter. If the request originates from your backend server, set this parameter to the user's sign-in IP address or the device's public IP address. We recommend specifying this IP address for user violation analysis. If this parameter is omitted, the server attempts to retrieve the IP address from the request URL or HTTP headers. |
|
os |
String |
No |
The operating system of the device. For example, Android 6.0. |
|
channel |
String |
No |
The channel ID. |
|
hostAppName |
String |
No |
The name of the host application. |
|
hostPackage |
String |
No |
The package name of the host application. |
|
hostVersion |
String |
No |
The version of the host application. |
Request example
POST /green/image/scan?clientInfo=%7b%22userId%22%3a%22120234234%22%2c%22userNick%22%3a%22Mike%22%2c%22userType%22%3a%22others%22%7d HTTP/1.1
Accept: application/json
Content-Type: application/json
Content-MD5: C+5Y0crpO4sYgC2DNjycug==
Date: Tue, 15 May 2018 10:16:36 GMT
x-acs-version: 2018-05-09
x-acs-signature-nonce: adfkjfaHKslkjf
x-acs-signature-version: 1.0
x-acs-signature-method: HMAC-SHA1
Authorization: acs q23Q9K4PaGi12Wyk:adFff0FFO6sGcDbDNjRtso==
Host: green.cn-shanghai.aliyuncs.com/
Content-Length: 191
{
"scenes": [
"porn"
],
"tasks": [
{
"dataId": "test2NInmO$tAON6qYUrtCRgLo-1mwxdi",
"url": "https://img.alicdn.com/tfs/TB1urBOQFXXXXbMXFXXXXXXXXXX-1442-257.png"
}
]
}
The request includes the following components:
-
POST: The request method. -
/green/image/scan: The request path. -
clientInfo=%7b%22userId%22%3a%22120234234%22%2c%22userNick%22%3a%22Mike%22%2c%22userType%22%3a%22others%22%7d: The URL-encoded common request parameter. -
The lines from
Accept: application/jsontoContent-Length: 191are the HTTP request headers. Among these, the headers fromAccept: application/jsontoAuthorization: acs q23Q9K4PaGi12Wyk:adFff0FFO6sGcDbDNjRtso==are the common request headers used for signature calculation. -
The content in
{}is the request body in JSON format. The structure of the request body varies by API operation. For details, see the documentation for the specific API operation.