3

I know how it can be done for Google Play Store (answer here), but i didn't manage to find a way for AppGallery. Thank you!

UPDATE #1

Using the answer below i partially solve this with this steps:

  1. Make an API Client with Administrator role, it also works with App Administrator and Operations. (documentaion here: API Client)
  2. Get the access token. (documentaion here: Obtaining a Token)
  3. Get app info. (documentaion here: Querying App Information)

The response from the Querying App Information, have a lot of informations about the app including "versionNumber", but for me it doesn't provide the "versionNumber" (the single info i needed), because this parameter is optional. And now i am stuck again, because i don't understand what i need to change in order to receive this one.

If anyone knows how I can solve this, thank you very much for your help.

UPDATE #2

@shirley's comment was right. The issue has been fixed in their latest release, and it has been released this month.

Ana-Maria
  • 41
  • 7
  • 1
    i have edited your question to try make it more clear that you're looking for a solution through code, if you're unhappy with my changes feel free to change it :) – a_local_nobody Jul 21 '20 at 11:55

1 Answers1

5

You can call the Querying App Information API (GET mode) to query the app details:

public static void getAppInfo(String domain, String clientId, String token, String appId, String lang) {
     HttpGet get = new HttpGet(domain + "/publish/v2/app-info?appid=" + appId + "&lang=" + lang);
     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();
             // Object returned by the app information query API, which can be received using the AppInfo object. For details, please refer to the API reference.
             JSONObject object = JSON.parseObject(result);
             System.out.println(object.get("ret"));
         }
     } catch (Exception e) {
     }
 }

They are mentioned here: Completing App Information, Querying App Information.

zhangxaochen
  • 32,744
  • 15
  • 77
  • 108
  • Thank you for the answer. I made a API client with administrator role, and made the request to Querying App Information,but the response doesn't have a "versionNumber". In documentation it is written that "versionNumber" is optional, but how can i make it show in the request's response? – Ana-Maria Jul 24 '20 at 10:04
  • @Anna Could you please leave your appId? Let me check the info to see the problem. Besides, much basic information about apps created in AGC is empty by default. [Completing App Information](https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Guides/agcapi-add_appinfo) describes how to complete app information through the Publishing API. – zhangxaochen Jul 25 '20 at 01:54
  • The app id is 102606985. In documentation it is written that you can update multiple informations [(Updating Basic App Information)](https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-References/agcapi-app-info_update_v2), but the "versionName" parameter isn't included. – Ana-Maria Jul 27 '20 at 10:03
  • 1
    @Anna Thank you for your contact. The issue has been fixed in their latest release, and it will be released by the end of August 2020. – zhangxaochen Jul 29 '20 at 02:11
  • HttpPost and HttpGet is already deprecated right? – ralphgabb Jul 27 '21 at 08:58