【问题标题】:Parameter applicationName must conform to the pattern (Google Report API)参数 applicationName 必须符合模式(Google Report API)
【发布时间】:2020-07-25 13:36:43
【问题描述】:

我需要通过 java 代码获取 google hangouts meet 数据,我正在尝试 google report api

以下是我的代码

String userKey = "all";
String applicationName = "meet";
String eventName = "call_ended";
Activities result = service.activities().list(userKey, applicationName).setEventName(eventName).setMaxResults(10).execute();

响应是

参数applicationName必须符合模式(admin)|(calendar)|(drive)|(login)|(token)

我正在尝试的api是这个,我可以通过相同的参数获取此链接中的数据

https://developers.google.com/admin-sdk/reports/v1/reference/activities/list

我也可以通过下面的java代码获取数据

public static String getGraph() {
        String PROTECTED_RESOURCE_URL = "https://www.googleapis.com/admin/reports/v1/activity/users/all/applications/meet?eventName=call_ended&maxResults=10&access_token=";
        String graph = "";
        try {
            URL urUserInfo = new URL(PROTECTED_RESOURCE_URL + "access_token");
            HttpURLConnection connObtainUserInfo = (HttpURLConnection) urUserInfo.openConnection();
            if (connObtainUserInfo.getResponseCode() == HttpURLConnection.HTTP_OK) {
                StringBuilder sbLines = new StringBuilder("");

                BufferedReader reader = new BufferedReader(
                        new InputStreamReader(connObtainUserInfo.getInputStream(), "utf-8"));
                String strLine = "";
                while ((strLine = reader.readLine()) != null) {
                    sbLines.append(strLine);
                }
                graph = sbLines.toString();
            }
        } catch (IOException ex) {
            ex.printStackTrace();
        }
        return graph;
    }

我认为这不是一个好的解决方案,我得到的是一个复杂的字符串

有什么解决办法吗!?

【问题讨论】:

    标签: google-admin-sdk google-reporting-api


    【解决方案1】:

    就用老版本的库google-api-services-admin-reports,我测试了以下版本:

      com.google.apis:google-api-services-admin-reports:reports_v1-rev83-1.25.0
    

    我的 gradle 文件:

    apply plugin: 'java'
    apply plugin: 'application'
    
    mainClassName = 'SdkAdminQuickStart'
    sourceCompatibility = 1.8
    targetCompatibility = 1.8
    version = '1.0'
    
    repositories {
        mavenCentral()
    }
    
    dependencies {
        compile 'com.google.api-client:google-api-client:1.23.0'
        compile 'com.google.oauth-client:google-oauth-client-jetty:1.23.0'
        compile 'com.google.apis:google-api-services-admin-reports:reports_v1-rev83-1.25.0'
    }
    

    【讨论】:

      【解决方案2】:

      这是Google Issue Tracker 上已经引用的已知错误;你可以查看here

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2018-04-24
        • 1970-01-01
        • 2018-05-20
        • 2018-09-14
        • 1970-01-01
        • 1970-01-01
        • 2019-03-27
        相关资源
        最近更新 更多