我收到类似
的错误com.google.api.client.googleapis.json.GoogleJsonResponseException:400错误请求 { “代码”:400, “错误”:[{ “域名”:“全球”, “message”:“无法一起查询所选维度和指标。”, “理由”:“badRequest” }], “消息”:“无法一起查询所选维度和指标。”
指标如下: “GA:uniquePurchases,GA:itemRevenue,GA:transactionTax,GA:transactionShipping
以下尺寸:“ga:productName”;
if (accessToken != null && refreshToken != null) {
JacksonFactory jacksonFactory = new JacksonFactory();
GoogleCredential credential =new GoogleCredential.Builder().setTransport(netHttpTransport)
.setJsonFactory(jacksonFactory).setClientSecrets(CLIENT_ID, CLIENT_SECRET).build();
credential.setAccessToken(accessToken);
credential.setRefreshToken(refreshToken);
analytics=new Analytics.Builder(netHttpTransport, jacksonFactory, credential).setApplicationName(APPLICATION_NAME).build();
try {
//AT a time we can get only 7 dimensions and 10 metrics
apiQuery = analytics.data().ga().get("ga:" + gleTokenInf.getProfileId(), TimeStamp1, TimeStamp2,getMetrics());
apiQuery.setDimensions(getDimensions());
gaData = apiQuery.execute();
log.info("Succesfully got the data for GA MOM Report from Analytics Interface ");
} catch (Exception ex) {
ex.printStackTrace();
}
}
答案 0 :(得分:0)
您无法在GA API中查询维度和指标的所有组合。如果ga:productName替换为ga:transactionId。
,则您的查询将有效此处测试API查询 - https://ga-dev-tools.appspot.com/query-explorer/