目录

Service Updates Sending API

Function Description

An atomic service calls the service updates sending API to deliver service updates messages.

Restrictions

Request Body Structure

[h2]API Prototype

[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.

[h2]Request Header

Parameter Description Example
Authorization

Authentication method:

JWT:

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

NOTE

· The PS256 algorithm must be used to call the service updates API.

· 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 eyJr*****OiIx---****.eyJh*****iJodHR--***.QRod*****4Gp---****

[h2]Request Body

Parameter Mandatory Type Description
toOpenId Yes String OpenID of a sign-in user. Use the OpenId reported by the device or request user information from the Account Kit server. For details about how to design and integrate the HUAWEI ID sign-in function, please refer to the account usage specifications of atomic services.
appId Yes String

App ID of an atomic service. The value contains 1 to 64 characters.

NOTE

[appId]: app ID. Sign in to AppGallery Connect, click Apps/Atomic services, select the required atomic service, and obtain the app ID of the atomic service under Basic information on the App information page.

sceneId Yes String Scenario ID. For details, please refer to Service Updates Sending Scenarios. The value contains 1 to 32 characters.
subSceneId Yes String Subscenario ID. For details, please refer to Service Updates Sending Scenarios. The value contains 1 to 32 characters.
code Yes String

· When a user launches the Huawei IAP checkout screen in your atomic service for payment, you can obtain the IAP order No. sysTransOrderNo and use it as the code.

· When a user obtains a code via a front-end scenario-specific button, you can use the Service Updates Authorization Code Button to retrieve the code.

content Yes TimelineStatusContent object.

Status parameter in service updates.

For the takeout self-pickup scenario, please refer to Takeout Self-Pickup Structure.

For the takeout delivery scenario, please refer to Takeout Delivery Structure.

Request Example

Send requests with mandatory and optional parameters based on different states. The following uses the takeout self-pickup scenario as an example.

Request example: preparing

// Request URL
POST "https://push-api.cloud.huawei.com/v1/[projectId]/service_timeline/send"
 
// Request Header
Content-Type: application/json
Authorization: Bearer eyJr*****OiIx---****.eyJh*****iJodHR--***.QRod*****4Gp---****

// Request Body
{
    "appId": "5**********7",
    "toOpenId": "A**********O",
    "sceneId": "10001",
    "subSceneId": "100010001",
    "code": "3**********7",
    "content": {
        "status": 3,
        "orderTime": 1716191520,
        "amount": "¥ 18.00",
        "productCount": 1,
        "productName": "Mango",
        "productImg": "image_test_1",
        "merchantName": "Store A",
        "pickupNumber": "1668",
        "pickupTime": "16:08",
        "remainOrders": "5 orders/5 cups",
        "waitTime": "10-20 minutes",
        "button": {
            "type": 0,
            "text": "Pickup code",
            "data": {
                "testKey": "testValue"
            }
        },
        "clickAction": {
            "type": 0,
            "data": {
                "testKey": "testValue"
            }
            
        },
        "appendButtons": [
            {
                "type": 0,
                "text": "Pickup code",
                "data": {
                    "testKey": "testValue"
                }
            }
        ]
    }
}

Request example: pending payment

// Request URL
POST "https://push-api.cloud.huawei.com/v1/[projectId]/service_timeline/send"
 
// Request Header
Authorization: Bearer eyJr*****OiIx---****.eyJh*****iJodHR--***.QRod*****4Gp---****

// Request Body
{
    "appId": "6**********3",
    "toOpenId": "A**********F",
    "sceneId": "10001",
    "subSceneId": "100010001",
    "code": "1**********6",
    "content": {
        "status": 1,
        "orderTime": 1715236319,
        "amount": "¥ 5.00",
        "productCount": 1,
        "productName": "Mango",
        "productImg": "image_test_1",
        "paymentEndTime": "Pay within 5 minutes",
        "merchantName": "Store B",
        "button": {
            "type": 0,
            "text": "Pay now",
            "action": "https://***"
        },
        "clickAction": {
            "type": 0,
            "action": "https://***"
        },
        "appendButtons": [
            {
                "type": 0,
                "text": "Pay now",
                "action": "https://***"
            }
        ]
    }
}

Response Parameters

[h2]Response Body

Parameter Mandatory Type Description
code Yes String Response code.
msg Yes String Response code description.
requestId Yes String Request ID.

Response Examples

Success response example:

{
  "code": "80000000",
  "msg": "Success",
  "requestId": "157*******006"
}

Failure response example:

{
  "code": "82600010",
  "msg": "status content missing required field",
  "requestId": "157*******006"
}

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. Check the Authorization parameter in the HTTP 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.
503 Traffic control.

· Distribute the sending speed evenly.

· Spread out push notification delivery to avoid peak sending times.

504 Gateway timeout. Try again later. If the fault persists, submit a ticket online.

Service Response Codes

[h2]80000000 Success

Message

Success.

Symptom

Sent successfully.

Possible causes

Sent successfully.

Solution

None.

[h2]82600001 Internal System Error

Message

system error.

Symptom

Internal system error.

Possible causes

An unknown error occurred.

Solution

Submit a ticket online.

[h2]82600002 Invalid Parameter

Message

invalid parameter {errorTips}.

Symptom

Parameter error.

Possible causes

Invalid parameter.

Solution

Verify the request parameters as prompted by the response.

[h2]82600003 Service Denied

Message

access deny.

Symptom

Service denied.

Possible causes

The service updates sending permission is not enabled.

Solution

Enable the service updates sending permission.

[h2]82600004 Risk Control Error

Message

status content blocked.

Symptom

Risk control error.

Possible causes

Some scenario parameters are prohibited.

Solution

Verify that the scenario parameters do not contain prohibited parameters as prompted by the response.

[h2]82600005 Service Updates Message Sending Failure

Message

send message failed{errorTips}.

Symptom

Failed to send the service updates message.

Possible causes

  1. There are no online recipients.

  2. The request body size exceeds the default value (4096 bytes).

Solution

Rectify the fault as follows:

  1. Verify that there are online recipients.

  2. Verify that the request body size does not exceed the default value (4096 bytes) and send the message again.

[h2]82600006 OpenID Verification Failure

Message

invalid openId.

Symptom

OpenID failed the verification.

Possible causes

The OpenID of the recipient is incorrect.

Solution

Use the OpenId reported by the client or the OpenId in the user information obtained from the Account Kit server.

[h2]82600007 Incorrect Scenario and Subscenario IDs

Message

invalid sceneId or subSceneId.

Symptom

The scenario and subscenario IDs are incorrect.

Possible causes

There is no permission on the scenario and subscenario.

Solution

Send the message based on enabled scenario and subscenario IDs.

[h2]82600008 Incorrect Authorization Code

Message

invalid code.

Symptom

The authorization code is incorrect.

Possible causes

  1. The transaction order ID is invalid.

  2. The transaction order ID is not activated within the validity period (1 hour).

Solution

Verify the following:

  1. The transaction order ID is valid.

  2. Regenerate the authorization code and push the message again.

Use the IAP order No. (sysTransOrderNo) as the authorization code to push the message again.

[h2]82600009 Incorrect Scenario-specific Status

Message

invalid scene status.

Symptom

The scenario-specific status is incorrect.

Possible causes

Incorrect request body parameter.

Solution

Verify the request body parameters as prompted by the response. For details, please refer to Service Updates Sending Scenarios.

[h2]82600010 Mandatory Status Parameters Are Missing

Message

status content missing required field {errorTips}.

Symptom

Mandatory status parameters are missing.

Possible causes

Mandatory status parameters are missing.

Solution

Verify the request body parameters as prompted by the response. For details, please refer to Service Updates Sending Scenarios.

[h2]82600011 Invalid Status Parameter Format

Message

status content has invalid field {errorTips}.

Symptom

The status parameter format is invalid.

Possible causes

The status parameter format is invalid.

Solution

Verify the request body parameters as prompted by the response.

[h2]82600012 Invalid Status Transition

Message

invalid status transition.

Symptom

Invalid status transition.

Possible causes

Invalid status transition.

Solution

[h2]82600013 Service Updates Push Disabled by User

Message

user close service.

Symptom

The user disabled the service updates push.

Possible causes

The user disabled the service updates push in this scenario.

Solution

Check whether the service updates switch is turned off. If so, turn on the switch and then call the API. To turn on the service updates switch, swipe right on the home screen to access Assistant·TODAY, touch the avatar to access the Me screen, touch the icon in the upper right corner of the screen, touch Manage live services, and find the corresponding scenario switch in the Service updates list.

[h2]82600014 Invalid Image Resource ID

Message

invalid image id.

Symptom

Invalid image resource ID.

Possible causes

The image resource specified by the resource ID does not exist.

Solution

Check whether the image resource specified by the resource ID exists. If not, use image resource hosting to provide the image and obtain the resource ID again.

[h2]82600015 Status Updates Quantity Exceeds Upper Limit

Message

status refresh frequency reached upper limit.

Symptom

The number of status updates exceeds the upper limit.

Possible causes

The number of status updates exceeds the upper limit.

Solution

Reduce unnecessary status updates.

[h2]82600016 Service Updates Expired

Message

event expired.

Symptom

Service updates expired.

Possible causes

After the time specified by expireTime elapses, service updates messages are not allowed.

Solution

Set expireTime properly and push the message again.

[h2]82600017 No Authorized Device

Message

no authorization device.

Symptom

The user does not have any authorized devices.

Possible causes

The user does not have any authorized devices in this scenario.

Solution

Add an authorized device for this scenario and push the message again.

Paths:

[h2]82600018 Service Updates Event Ended

Message

event already closed.

Symptom

The service updates event has ended.

Possible causes

The event has ended. No more messages can be sent.

Solution

Create a new service updates event to push messages.

[h2]82600019 Active Authorization Code Quantity Exceeds Upper Limit

Message

code reached upper limit.

Symptom

The number of active authorization codes exceeds the upper limit.

Possible causes

The number of authorization codes pushed to the same user exceeds the upper limit (50).

Solution

Limit the number of authorization codes pushed to a single user to a maximum of 50.