目录

Image Risk Control

Function Description

This API is used to check for risks of an image that is to be sent.

Restrictions

Each app can make a maximum of 60 API calls per minute. If this limit is exceeded, error code 83010002 will be returned.

This API is used only for pushing messages. Do not modify images that have passed the image risk check, as this may prevent notification messages from being displayed properly.

API Prototype

  • [clientId]: OAuth 2.0 client ID (credential). To obtain the value, sign in to AppGallery Connect, click Development and services, click the desired project, and go to Project settings.

  • [projectId]: project ID. To obtain the value, sign in to AppGallery Connect, click Development and services, click the desired project, and go to Project settings.

  • The two URLs point to the same API, but only differ in the authentication mode. You can use either of them.

Request Parameters

Request Header

Parameter Description Example
Authorization

Authentication method:

JWT:

For details, please refer to Generating a JWT Based on a Service Account.

NOTE

You are advised to set the JWT validity period to 3600 seconds, within which a JWT can be reused.

This parameter value is Bearer followed by a space character and then the obtained authentication information.

Bearer eyJraWQiOiIx---xxx.eyJhdWQiOiJodHR---xxx.QRodgXa2xeXSt4Gp---xxx
push-type

Message type. The options are as follows:

0: sends a notification containing a large icon

1: updates the image on a service widget

2: sends a text-to-speech message containing a large icon

1

Request Body

Parameter Mandatory Type Description
imageUrl Yes String Public URL of the image to be verified. It must use the HTTPS protocol.

Request Example

{
    "imageUrl": "https://example.com/image.png"
}

Response Parameters

Response Body

Parameter Mandatory Type Description
code Yes String Response code.
msg Yes String Response code description.
requestId No String Request ID.
downloadUrl No String URL of the image that passes the risk check. (This parameter is returned only when the API call is successful.) This value is generated by the Huawei Push server by appending a risk control verification key to the original URL, ensuring that the image source is legitimate and tamper-proof. It can be used as the image URL for scenarios such as the large icon on the right side of a notification (corresponding to the image parameter of Notification) and service widget image (corresponding to the url parameter of FormImage).
expireTime No String Expiration time of the image risk check, which is a Unix timestamp in seconds. (This parameter is returned only when the API call is successful.)

Response Example

Success response example:

{
    "code": "83010000",
    "msg": "Verify success",
    "requestId": "1631***********0101",
    "downloadUrl": "https://**.png?verifyKey=MEUCIQDzfYMReU*****************fdCOX9KToGq7o%3D",
    "expireTime": "1689911616"
}

Failure response example:

{
    "code": "83010005",
    "msg": "Download picture failed",
    "requestId": "1691***********1501"
}

HTTP Response Codes

HTTP Response Code Description Solution
200 Success. -
400 Parameter error. Check the service response code and locate the fault based on it.
401 Authentication failure. Verify the JWT in the Authorization parameter in the HTTP request header.
404 Service not found. Check the request URL.
500 Internal service error. Submit a ticket online.
502 Connection error. This typically occurs when network connectivity is unstable. Try again later. If the fault persists, submit a ticket online.

Service Response Codes

[h2]80100001 Parameter Error

Message

Check Parameter Error.

Symptom

Parameter error.

Possible causes

Parameter error.

Solution

Check and modify request parameters as prompted by the response.

[h2]80100003 Invalid URL Format

Message

only https allow.

Symptom

Invalid URL format.

Possible causes

Invalid URL format.

Solution

Verify that imageUrl uses the HTTPS protocol as prompted by the response.

[h2]80200001 Authentication Error

Message

Authentication Error.

Symptom

Authentication error.

Possible causes

  1. The request does not contain the Authorization parameter, or the Authorization parameter is left empty.

  2. The project ID used for JWT application is different from that contained in the push request.

  3. The JWT in the Authorization parameter does not match the app.

Solution

Rectify the authentication failure of the Authorization parameter in the request header as prompted by the response.

  1. Verify that the request contains the Authorization parameter, and the Authorization parameter is not empty.

  2. Verify that the value of projectId in the push request URL (https://push-api.cloud.huawei.com/v2/[projectId]/images:verify) is the same as the ID of the project to which your app belongs. For details, please refer to step 2 in Generating a JWT Based on a Service Account.

  3. Verify that the JWT in the Authorization parameter matches the actual app. For details, please refer to Generating a JWT Based on a Service Account.

Generate a new JWT and then send the message.

[h2]80200003 Access Token Expired

Message

Access token expired.

Symptom

The access token has expired.

Possible causes

The access token has expired.

Solution

Generate a new JWT as prompted by the response and then send the request. For details, please refer to Generating a JWT Based on a Service Account.

[h2]80200005 JWT Expired

Message

Jwt token expired.

Symptom

The JWT has expired.

Possible causes

The JWT has expired.

Solution

Generate a new JWT as prompted by the response and then send the request. For details, please refer to Generating a JWT Based on a Service Account.

[h2]80300002 No Permission

Message

No permission to send message to these tmIDs.

Symptom

No permission.

Possible causes

Push Kit has not been enabled for the project.

Solution

Enable Push Kit in AppGallery Connect.

[h2]83010000 Image Passes Risk Check

Message

Verify success.

Symptom

The image passes the risk check.

Possible causes

The image passes the risk check.

Solution

None

[h2]83010001 Image Failed Risk Check

Message

Verify failed.

Symptom

The image failed the risk check.

Possible causes

The image contains sensitive information.

Solution

Modify the image as prompted by the response and perform risk check on the image again.

[h2]83010002 Traffic Control Threshold Exceeded

Message

The number of sent messages exceeds the limit.

Symptom

The request frequency exceeds the traffic control threshold.

Possible causes

The request frequency exceeds the traffic control threshold (60 requests per minute per app).

Solution

Reduce the request frequency and try again.

[h2]83010003 Empty Request Body

Message

Request body is empty.

Symptom

The request body is empty.

Possible causes

The request body is empty.

Solution

Check and modify the request body as prompted by the response.

[h2]83010004 Risk Check Not Supported

Message

Send control is not supported.

Symptom

Risk check is not supported.

Possible causes

No risk check policy is matched.

Solution

If no risk control policy is matched, submit a ticket online.

[h2]83010005 Image Download Failure

Message

Download picture failed.

Symptom

Failed to download the image.

Possible causes

The image URL in the request body is incorrect.

Solution

Verify the image URL in the request body as prompted by the response.

[h2]83010007 Incorrect Message Type

Message

The header does not contain valid push-type.

Symptom

Incorrect message type.

Possible causes

Incorrect message type.

Solution

Verify push-type as prompted by the response.