0

I am trying to use this api to get report with java, and here is the link

https://developers.google.com/admin-sdk/reports/v1/appendix/activity/meet

and here is what i am using now

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) {
            x.printStackTrace();
    }
    return graph;
}

I am pretty sure it's not a smart way to do that and the string I get is quite complex, are there any jave sample that i can get the data directly instead of using java origin httpRequest

Or, are there and class I can import to switch the json string to the object!?

Anyone can help?!

I have trying this for many days already!

Thanks!!

蘇柏綸
  • 39
  • 1
  • 10
  • Have you looked at the [Java Quickstart for the Reports API](https://developers.google.com/admin-sdk/reports/v1/quickstart/java) and modified that? – Rafa Guillermo Apr 13 '20 at 08:22
  • Here is another issue i just test https://stackoverflow.com/questions/61180352/parameter-applicationname-must-conform-to-the-pattern-google-report-api – 蘇柏綸 Apr 13 '20 at 08:56
  • @Rafa Guillermo I try that quickstart and it works but while I change my parameters, it response some error message. But I can get data by those parameters at the test page – 蘇柏綸 Apr 13 '20 at 08:58
  • When you say `it response some error message.` what message do you get? – Rafa Guillermo Apr 13 '20 at 09:36
  • Parameter applicationName must conform to the pattern (admin)|(calendar)|(drive)|(login)|(token) – 蘇柏綸 Apr 13 '20 at 09:43
  • Can you post your whole `Activities: list` script with the request, call and build methods? – Rafa Guillermo Apr 13 '20 at 14:13

0 Answers0