Function: This API is used to subscribe to a topic for one or more users.
Restrictions: A maximum of 1000 tokens are allowed in each call request. Currently, this API only supports Android apps.
Protocol | HTTPS POST |
Direction | App server -> HUAWEI Push Kit server |
URL | https://push-api.cloud.huawei.com/v1/[appid]/topic:subscribe |
Request Parameters (HTTP Header)
Parameter | Description | Example |
Authorization | For details, please refer to Open Platform Authentication - Client Password Mode. Notice: A space character must be added between Bearer and the value of access_token. | Bearer CF3Xl2XV6jMKZgqYSZFws9IPlgDvxqOfFSmrlmtkTRupbU2VklvhX9kC9JCnKVSDX2VrDgAPuzvNm3WccUIaDg== |
Request Parameters (HTTP Body)
Parameter | Type | Mandatory (M)/Optional (O) | Description |
topic | string | M | Name of the topic to be subscribed to. The value can contain a maximum of 900 characters, including only digits, letters, underscores (_), dots (.), tildes (~), percent signs (%), and Chinese. |
tokenArray[] | string | M | Token list, which can contain a maximum of 1000 tokens. Example: ["pushtoken1","pushtoken2"] |
Response Parameters
Parameter | Type | Description |
code | string | Result code. |
msg | string | Result code description. |
requestId | string | Request ID. |
failureCount | integer | Number of devices for which the topic fails to be subscribed to. |
successCount | integer | Number of devices for which the topic is successfully subscribed to. |
errors | array | Error list. index: incorrect token index. reason: error description. |
Sample request code:
- {
- "topic": "weather",
- "tokenArray": [
- "pushtoken1",
- "pushtoken2"
- ]
- }
Sample response code:
- {
- "msg": "Success",
- "code": "80000000",
- "requestId": "157466304904000004000701",
- "successCount": 2,
- "failureCount": 0,
- "errors": []
- }
HTTP Status Code | Description | Solution |
200 | OK | N/A |
400 | Incorrect parameter. | Check the status code in the response and rectify the fault based on the status code. |
401 | Authentication failed. | Check the access token in the Authorization parameter in the request HTTP header. |
404 | Service not found. | Check whether the request URL is correct. |
500 | Internal service error. | Contact Huawei technical support. |
Service Result Code | Description | Solution |
80000000 | Success. | N/A |
80100001 | Incorrect parameter. | Check parameters. |
80200001 | OAuth authentication error. | The access token in the Authorization parameter in the request HTTP header failed to be authenticated. Ensure that the access token is correct. |
80200003 | OAuth token expired. | The access token in the Authorization parameter in the request HTTP header expired. Apply for a new access token. |
80400005 | Not data storage location selected. | Select a data storage location for the app in AppGallery Connect. |
80400006 | The data storage location is inconsistent with the actual one. | Contact Huawei technical support. |
82000007 | Invalid topic name. | Check the topic parameter. |
82000008 | The tokenArray parameter is left empty or its value exceeded the threshold. | Check the tokenArray parameter. |
82000009 | The number of topics exceeded the threshold (2000). | Check the topic parameter. |
82000010 | Some tokens failed to be processed. | Check the parameters of the tokens that failed to be processed. |