Intelligent Assistant
Chat with our virtual assistant to get answers promptly.
This API is used to query information about devices.
Protocol | HTTPS GET |
|---|---|
Direction | Your server -> Huawei server |
URL | https://connect-api.cloud.huawei.com/api/publish/v2/device/list |
Data Format | Request: Content-Type: application/json Response: Content-Type: application/json |
This API supports the Service Account, API client, and OAuth client modes. For details about their differences, please refer to Obtaining Authorization from the Server.
Service Account mode
Parameter | Mandatory | Type | Description |
|---|---|---|---|
Authorization | Yes | String | Authorization information in Authorization: Bearer ${JWT} format. Here JWT is the authentication token obtained when you obtain authorization using the Service Account mode. |
API client mode
Parameter | Mandatory | Type | Description |
|---|---|---|---|
client_id | Yes | String | Client ID. For details about how to obtain the value, please refer to Creating an API Client. |
Authorization | Yes | String | Authorization information in Authorization: Bearer ${access_token} format. In the format, access_token is obtained in Obtaining a Token. |
OAuth client mode
Parameter | Mandatory | Type | Description |
|---|---|---|---|
teamId | Yes | String(64) | ID of the team that you belong to. |
oauth2Token | Yes | String | Authorization information. Pass the access token obtained via the API for obtaining an access token. |
Parameter | Mandatory | Type | Description |
|---|---|---|---|
deviceName | No | String(256) | Device name. Fuzzy search is supported. |
fromRecCount | No | Integer(32) | Start page number. Minimum value: 1 Default value: 1 |
maxReqCount | No | Integer(32) | Number of records returned on each page. Value range: 1 to 100 Default value: 20 |
order | No | Integer(32) | Result sorting mode. The options are as follows:
|
- GET /api/publish/v2/device/list?deviceName=testDevice HTTP/1.1
- Host: connect-api.cloud.huawei.com
- client_id: 41******68
- Content-Type: application/json
- Authorization: Bearer ******
Parameter | Mandatory | Type | Description |
|---|---|---|---|
ret | Yes | Result code and description. | |
totalCount | Yes | Integer(32) | Total number of records. |
deviceList | No | List<DeviceInfo> | Device details. |
- {
- "ret": {
- "code": 0,
- "msg": "success"
- },
- "deviceList": [
- {
- "id": "14***************80",
- "deviceName": "testDevice"
- "udid": "111111111222****************************************333333444444",
- "deviceType": 1,
- "createTime": "2024-06-14 11:55:28.676",
- }
- ],
- "totalCount": 1
- }
Java sample code:
- public static JSONObject getDeviceList(String domain, String clientId, String token, String deviceName) {
- HttpGet get = new HttpGet(domain + "/publish/v2/device/list?deviceName=" + deviceName);
-
- get.setHeader("Authorization", "Bearer " + token);
- get.setHeader("client_id", clientId);
- try {
- CloseableHttpClient httpClient = HttpClients.createDefault();
- CloseableHttpResponse httpResponse = httpClient.execute(get);
- int statusCode = httpResponse.getStatusLine().getStatusCode();
- if (statusCode == HttpStatus.SC_OK) {
- BufferedReader br = new BufferedReader(
- new InputStreamReader(httpResponse.getEntity().getContent(), Consts.UTF_8));
- String result = br.readLine();
-
- return JSON.parseObject(result);
- }
- } catch (Exception ignored) {
-
- }
- return null;
- }