### Download Domain Configuration File Request Example Source: https://developer.huawei.com/consumer/cn/doc/app/agc-help-domain-api-download-domain-config-0000002271160653 This example demonstrates how to make a GET request to download the domain configuration file. Ensure you include the correct Authorization header, client_id, and appId. ```HTTP GET /api/dms/domain-manage/v1/app/domain/verify-file HTTP/1.1 Host: connect-api.cloud.huawei.com client_id: 4141******68 Content-Type: application/json Authorization: Bearer ******* appId: 10******57 ``` -------------------------------- ### Example of Version Code Mismatch Source: https://developer.huawei.com/consumer/cn/doc/app/agc-help-inhouse-0000002281532696 Shows an example of how differing 'versionCode' values in the description file and module.json can lead to application installation errors. ```json 1. "versionCode": 1000001, ``` ```json 1. "versionCode": 1000000, ``` ```json 1. "versionCode": 1000000, ``` ```json 1. "versionCode": 1000000, ``` -------------------------------- ### Batch Add Devices Request Example Source: https://developer.huawei.com/consumer/cn/doc/app/agc-help-provision-api-add-device-0000002236041498 This example demonstrates the structure of a POST request to the Provisioning API for batch adding devices. Ensure the Content-Type is set to application/json. ```http POST /api/publish/v2/device HTTP/1.1 Host: connect-api.cloud.huawei.com client_id: 41******68 Content-Type: application/json Authorization: Bearer ****** { "deviceList": [ { "deviceName": "testDevice", "udid": "111111111222****************************************333333444444", "deviceType": 1 } ] } ``` -------------------------------- ### Request Example for Querying Certificate Fingerprints Source: https://developer.huawei.com/consumer/cn/doc/app/agc-help-provision-api-get-fingerprints-0000002431361316 This snippet shows an example HTTP GET request to the Provisioning API to retrieve certificate fingerprints. It includes necessary headers such as Host, client_id, Content-Type, Authorization, and appId. ```http GET /api/provision/v1/fingerprints HTTP/1.1 Host: connect-api.cloud.huawei.com client_id: 41******68 Content-Type: application/json Authorization: Bearer ****** appId: 1********57 ``` -------------------------------- ### Submit App for Review Request Example Source: https://developer.huawei.com/consumer/cn/doc/app/agc-help-publish-api-app-submit-0000002271160585 This example demonstrates the structure of a POST request to submit an application for review, including all relevant parameters in the body. ```HTTP POST /api/publish/v3/app-submit HTTP/1.1 Host: connect-api.cloud.huawei.com client_id: 414*******68 Content-Type: application/json; Authorization: Bearer ***** appId: 1******57 { "releaseTime": "2015-01-01T01:01:01+0800", "remark": "", "releaseType": 1, "releasePhase": 3, "phasedReleaseDescription": "******" } ``` -------------------------------- ### Java Example for Fetching HarmonyOS App Download Report Source: https://developer.huawei.com/consumer/cn/doc/app/agc-help-report-api-guide-0000002271134669 This Java code demonstrates how to obtain an access token and then use it to request the download URL for a HarmonyOS app's download and installation report. Ensure you have completed server-side authorization before running this code. ```java 1. package com.huawei.appgallery.connect.gateway.core; 2. 3. public class ReportApiDemo { 4. public static void main(String[] args) { 5. getReport(getToken(), "101236389", "zh-CN", "20240501", "20240630"); 6. } 7. 8. public static String getToken() { 9. HttpPost post = new HttpPost("https://x.x.x.x/api/oauth2/v1/token"); 10. JSONObject keyString = new JSONObject(); 11. keyString.put("client_id", "205401****9936"); 12. keyString.put("client_secret", "C287F53841C1A29BD049****04C1A8A8E93C432671A553DCC2DC9352"); 13. keyString.put("grant_type", "client_credentials"); 14. ... ... // 发送POST请求,response中获取access_token字段 15. return token; // 获取token 16. } 17. 18. public static String getReport(String token, String appId, String language, String startTime, String endTime) { 19. HttpGet get = new HttpGet( 20. "https://x.x.x.x/api/report/harmony-report/v1/harmony/appDownloadAnalysisExport/" + appId + "?" 21. + "language=" + language + "&startTime=" + startTime + "&endTime=" + endTime); 22. get.setHeader("Authorization", "Bearer " + token); 23. get.setHeader("client_id", "205401****9936"); 24. ... ... // 发送GET请求,获取响应中的获取报表的下载路径 25. } 26. } ``` -------------------------------- ### Example of Bundle Name Mismatch Source: https://developer.huawei.com/consumer/cn/doc/app/agc-help-inhouse-0000002281532696 Illustrates how a mismatch in the 'bundleName' field between the description file and the module.json file can cause installation failures. ```json 1. "bundleName": "com.huawei.enterprise.demoA" ``` ```json 1. "bundleName": "com.huawei.enterprise.demoB" ``` ```json 1. "bundleName": "com.huawei.enterprise.demo" ``` ```json 1. "bundleName": "com.huawei.enterprise.demo" ``` -------------------------------- ### HarmonyOS App Download Analysis Export Source: https://developer.huawei.com/consumer/cn/doc/app/agc-help-report-api-guide-0000002271134669 This example demonstrates how to obtain the download URL for HarmonyOS app download and installation reports. It includes steps for obtaining an access token and then calling the API to get the report file URL. ```APIDOC ## GET /api/report/harmony-report/v1/harmony/appDownloadAnalysisExport/{appId} ### Description Retrieves the download URL for HarmonyOS app download and installation analysis reports. ### Method GET ### Endpoint /api/report/harmony-report/v1/harmony/appDownloadAnalysisExport/{appId} ### Parameters #### Path Parameters - **appId** (string) - Required - The unique identifier of the application. #### Query Parameters - **language** (string) - Required - The language code for the report (e.g., "zh-CN"). - **startTime** (string) - Required - The start date for the report data (format: YYYYMMDD). - **endTime** (string) - Required - The end date for the report data (format: YYYYMMDD). #### Headers - **Authorization** (string) - Required - Bearer token for authentication (e.g., "Bearer [access_token]"). - **client_id** (string) - Required - The client ID obtained during authorization. ### Request Example ```java // Assuming 'token' is obtained from getToken() method String token = getToken(); String appId = "101236389"; String language = "zh-CN"; String startTime = "20240501"; String endTime = "20240630"; HttpGet get = new HttpGet( "https://x.x.x.x/api/report/harmony-report/v1/harmony/appDownloadAnalysisExport/" + appId + "?" + "language=" + language + "&startTime=" + startTime + "&endTime=" + endTime); get.setHeader("Authorization", "Bearer " + token); get.setHeader("client_id", "205401****9936"); // ... send GET request and process response ... ``` ### Response #### Success Response (200) - **fileURL** (string) - The URL to download the report file (CSV or Excel). #### Response Example ```json { "fileURL": "https://example.com/path/to/your/report.csv" } ``` ``` -------------------------------- ### Java Example for Adding Devices Source: https://developer.huawei.com/consumer/cn/doc/app/agc-help-provision-api-add-device-0000002236041498 This Java code snippet shows how to construct and execute a POST request to the Provisioning API for adding a device. It handles setting headers, constructing the JSON body, and processing the response. ```java public static JSONObject addDevice(String domain, String clientId, String token, String deviceName, String udid, Integer deviceType) { HttpPost post = new HttpPost(domain + "/publish/v2/device"); post.setHeader("Authorization", "Bearer " + token); post.setHeader("client_id", clientId); JSONObject keyString = new JSONObject(); JSONArray jsonArray = new JSONArray(); JSONObject deviceJson = new JSONObject(); deviceJson.put("deviceName", deviceName); deviceJson.put("udid", udid); deviceJson.put("deviceType", deviceType); jsonArray.add(deviceJson); keyString.put("deviceList", jsonArray); StringEntity entity = new StringEntity(keyString.toString(), StandardCharsets.UTF_8); entity.setContentEncoding("UTF-8"); entity.setContentType("application/json"); post.setEntity(entity); try { CloseableHttpClient httpClient = HttpClients.createDefault(); CloseableHttpResponse httpResponse = httpClient.execute(post); 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; } ``` -------------------------------- ### Request Example for Querying App ID Source: https://developer.huawei.com/consumer/cn/doc/app/agc-help-publish-api-appid-list-0000002271000617 This example demonstrates how to make a GET request to the appid-list endpoint to retrieve an App ID for a given package name. ```HTTP GET /api/publish/v2/appid-list?packageName=com.huawei.xxxx HTTP/1.1 Host: connect-api.cloud.huawei.com client_id: 41*******7168 Authorization: Bearer ******* ``` -------------------------------- ### Example API Request Header Source: https://developer.huawei.com/consumer/cn/doc/app/agc-help-connect-api-obtain-server-auth-0000002271134661 This snippet shows an example of an HTTP GET request to a demo endpoint, including the Authorization header with a Bearer token for authentication. ```http GET /v1/demo/indexes HTTP/1.1 Authorization: Bearer eyJraWQiOiIx******.eyJhdWQiOiJodHR******.QRodgXa2xeXSt4Gp****** Host: connect-api.cloud.huawei.com ``` -------------------------------- ### Create User Agreement Request Example Source: https://developer.huawei.com/consumer/cn/doc/app/agc-help-publish-api-create-user-agreement-0000002271160581 This example demonstrates how to construct a POST request to create a user agreement, including specifying the agreement type, default language, and details for multiple language versions of the agreement. ```http POST /api/publish/v2/agreement HTTP/1.1 Host: connect-api.cloud.huawei.com client_id: 414*******68 Content-Type: application/json; Authorization: Bearer ***** appId: 1******57 { "type": 2, "channel": 1, "defaultLang": "zh", "agreementInfos": [ { "lang": "zh", "baseInfo": { "name": "新增", "agreementTitle": "新增中文", "userAgreementUrl": "https://*****/****/****" } }, { "lang": "en", "baseInfo": { "name": "新增", "agreementTitle": "新增英文", "userAgreementUrl": "https://*****/****/****" } }, { "lang": "zh-Hant-HK", "baseInfo": { "name": "新增", "agreementTitle": "香港", "userAgreementUrl": "https://*****/****/****" } } ] } ``` -------------------------------- ### 配置SDK依赖 - 方式二 Source: https://developer.huawei.com/consumer/cn/doc/app/agc-help-auth-integration-sdk-0000002236337006 通过命令行安装SDK到您的项目中。 ```bash 1. ohpm install @hw-agconnect/auth ``` -------------------------------- ### Request Example for Querying Required Qualification Information Source: https://developer.huawei.com/consumer/cn/doc/app/agc-help-publish-api-query-tag-qual-dependent-0000002271160577 This example shows how to make a GET request to the API endpoint to retrieve the required qualification information. Ensure you include the correct Host, client_id, Content-Type, and Authorization header. ```http GET /api/publish/v2/tag-qual-dependent HTTP/1.1 Host: connect-api.cloud.huawei.com client_id: 414*******68 Content-Type: application/json Authorization: Bearer ****** ``` -------------------------------- ### Example of Min API Version Mismatch Source: https://developer.huawei.com/consumer/cn/doc/app/agc-help-inhouse-0000002281532696 Demonstrates a scenario where a mismatch in 'minAPIVersion' between the description file and module.json causes installation issues. ```json 1. "minAPIVersion": 5.0.0(12) ``` ```json 1. "minAPIVersion": 50000011 ``` ```json 1. "minAPIVersion": 5.0.0(12) ``` ```json 1. "minAPIVersion": 50000012 ``` -------------------------------- ### init Source: https://developer.huawei.com/consumer/cn/doc/app/agc-help-auth-api-auth-0000002273777093 Initializes the Auth SDK with the application context and configuration JSON. This is a prerequisite for using other Auth services. ```APIDOC ## init ### Description Initializes the Auth SDK. ### Method init(applicationContext: Context, json: String): void ### Parameters #### Path Parameters - **applicationContext** (Context) - Required - The application context. - **json** (String) - Required - A JSON string generated from the agconnect-services.json file. ### Request Example ```javascript import auth from '@hw-agconnect/auth'; onCreate(want, launchParam) { let file = this.context.resourceManager.getRawFileContentSync('agconnect-services.json'); let json: string = buffer.from(file.buffer).toString(); auth.init(this.context, json); } ``` ``` -------------------------------- ### Java Example for Querying Certificates Source: https://developer.huawei.com/consumer/cn/doc/app/agc-help-provision-api-query-cent-0000002271160629 This Java code demonstrates how to make an HTTP POST request to query certificates using the Provisioning API. It configures the request with necessary headers and a JSON entity, then executes the request and parses the JSON response. ```Java public static JSONObject getCertList(String domain, String clientId, String token, Integer certType, List certIds) { HttpPost post = new HttpPost(domain + "/publish/v3/cert/list"); post.setHeader("Authorization", "Bearer " + token); post.setHeader("client_id", clientId); JSONObject keyString = new JSONObject(); keyString.put("certType", certType); keyString.put("certIds", certIds); StringEntity entity = new StringEntity(keyString.toString(), StandardCharsets.UTF_8); entity.setContentEncoding("UTF-8"); entity.setContentType("application/json"); post.setEntity(entity); try { CloseableHttpClient httpClient = HttpClients.createDefault(); CloseableHttpResponse httpResponse = httpClient.execute(post); 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; } ``` -------------------------------- ### GET Request to Query App Package Information Source: https://developer.huawei.com/consumer/cn/doc/app/agc-help-publish-api-query-package-info-0000002328848469 This example demonstrates how to make a GET request to the AppGallery Connect API to retrieve information about a specific app package. Ensure you include the correct authorization headers, client ID (if applicable), and the appId. ```HTTP GET /api/publish/v2/app-package-info?packageId=10004151 HTTP/1.1 Host: connect-api.cloud.huawei.com client_id: 414*******68 Content-Type: application/json Authorization: Bearer ****** appId: 1******57 ``` -------------------------------- ### App Description File (manifest.json5) Source: https://developer.huawei.com/consumer/cn/doc/app/agc-help-internal-test-release-app-0000002260691994 This JSON file describes your application, including bundle information, version details, module configurations, and download URLs for HAP/HSP packages. Ensure all URLs start with 'https' and deploy domains match. ```json { "app": { "bundleName": "com.example.demo.a", "bundleType": "app", "versionCode": 1000000, "versionName": "1.0.0", "label": "DemoA", "deployDomain": "应用、图标以及描述文件部署域名", "icons": { "normal": "标准图标下载链接", "large": "大图标下载链接" }, "minAPIVersion": "4.1.0(11)", "targetAPIVersion": "4.1.0(11)", "modules": [ { "name": "module1", "type": "entry", "deviceTypes": [ "tablet", "2in1", "phone" ], "packageUrl": "HAP包下载链接", "packageHash": "HAP包sha256值" }, { "name": "module2", "type": "feature", "deviceTypes": [ "tablet", "2in1", "phone" ], "packageUrl": "HAP包下载链接", "packageHash": "HAP包sha256值" }, { "name": "module3", "type": "shared", "deviceTypes": [ "tablet", "2in1", "phone" ], "packageUrl": "HSP包下载链接", "packageHash": "HSP包sha256值" } ] }, "sign": "描述文件签名" } ``` -------------------------------- ### Request Example for Querying Restricted ACL Permission Status Source: https://developer.huawei.com/consumer/cn/doc/app/agc-help-provision-api-getaclapplystatus-0000002469246150 This example demonstrates how to make a GET request to the Provisioning API to check the status of restricted ACL permission applications. Ensure you include the correct Host, client_id, Content-Type, Authorization, and appId headers. ```HTTP GET /api/provision/v1/user/permission/apply/status HTTP/1.1 Host: connect-api.cloud.huawei.com client_id: 414*******68 Content-Type: application/json Authorization: Bearer ****** appId: 1******57 ``` -------------------------------- ### Get HarmonyOS App Download and Installation Report File Source: https://developer.huawei.com/consumer/cn/doc/app/agc-help-report-api-app-download-export-0000002271000737 Retrieves a report file containing data on HarmonyOS app downloads and installations. The report can be filtered by date, country, app version, province, city, and device, and can be grouped by various criteria. The output format can be CSV or Excel. ```APIDOC ## GET /api/report/harmony-report/v1/harmony/appDownloadAnalysisExport/{appId} ### Description Retrieves a report file containing data on HarmonyOS app downloads and installations. The report can be filtered by date, country, app version, province, city, and device, and can be grouped by various criteria. The output format can be CSV or Excel. ### Method GET ### Endpoint https://connect-api.cloud.huawei.com/api/report/harmony-report/v1/harmony/appDownloadAnalysisExport/{appId} ### Parameters #### Path Parameters - **appId** (String(32)) - Required - Application ID. #### Query Parameters - **startTime** (String) - Required - Query start time in UTC. Format: YYYYMMDD. Must be within 180 days of endTime. - **endTime** (String) - Required - Query end time in UTC. Format: YYYYMMDD. Must be within 180 days of startTime. - **timeType** (String) - Optional - Time type for querying. Possible values: day, week, month. - **language** (String(10)) - Required - Query language. Supported values: zh-CN, en-US, ru-RU. - **filterCondition** (List) - Optional - Filter criteria. Possible values: countryId, appVersion, province, city, deviceName. Multiple conditions can be used. - **filterConditionValue** (List) - Optional - Values corresponding to the filterCondition. The order must match filterCondition. For countryId, use country codes (e.g., "CN, AL, AT"); for appVersion, use version strings (e.g., "1.0.0,2.0.0"); for province/city, use names (e.g., "上海市"); for deviceName, use model names (e.g., "Mate30Pro-5G"). - **groupBy** (String) - Optional - Data statistics grouping information. Possible values: date, countryId, appVersion, province, city, deviceName. Defaults to 'date'. - **exportType** (String) - Optional - Export file type. Possible values: CSV, EXCEL. Defaults to 'CSV'. ### Response #### Success Response (200) - **fileURL** (String) - Required - Path to the exported CSV or Excel file. The language of the report fields is specified by the 'language' parameter. The first field is the grouping type specified by the 'groupBy' parameter. - **ret** (ConnectRet) - Required - Result containing return code and description. #### Response Example { "fileURL": "https://example.com/path/to/your/report.csv", "ret": { "code": 0, "msg": "Success" } } ``` -------------------------------- ### Provision API Request Example Source: https://developer.huawei.com/consumer/cn/doc/app/agc-help-provision-api-apply-provision-0000002271000689 This snippet shows a sample POST request to the /api/publish/v3/provision endpoint. It includes necessary headers like Host, client_id, Content-Type, and Authorization, along with a JSON payload containing provision details. ```http POST /api/publish/v3/provision HTTP/1.1 Host: connect-api.cloud.huawei.com client_id: 41******68 Content-Type: application/json Authorization: Bearer ****** { "provisionName": "testProvision", "provisionType": 1, "certId": "34******28", "appId": "69****117", "deviceIdList": [ "14****208" ], "aclPermissionList": [ "" ] } ```