2017-02-21 182 views
0

我已经得到了如下的错误com.google.api.client.googleapis.json.GoogleJsonResponseException:400错误的请求

com.google.api.client.googleapis.json.GoogleJsonResponseException:400错误的请求 { “代码”:400, “错误”:[{ “结构域”: “全局”, “消息”: “选择的维度和度量不能一起查询。”, “原因”: “错误请求” }], “消息”:“选定的维度和指标不能一起查询。”

指标均低于: “GA:uniquePurchases,GA:itemRevenue,GA:transactionTax,GA:transactionShipping下面

尺寸: “GA:产品名称”;

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(); 
      } 
     } 
+1

可能出现[Google AnalyticsAPI错误“无法一起查询所选维度和指标”的重复。](http://stackoverflow.com/questions/29152101/google-analytics-api-error-selected-dimensions-and -metrics-can-be-queried-to) – DaImTo

回答