2016-07-15 54 views
0

张贴JSON我想嵌套JSON输入后进入赛酷server.I得到了成功的邮递员,但同时我在Java代码中我试图我有一个错误,如错误而使用JSOUP概念

Errorjava.lang.IllegalArgumentException: Data value must not be null 

以下是我的代码发布嵌套的JSON到saiku服务器。

   // nested JSON 
      JSONObject object = new JSONObject(); 
      JSONObject querymodel = new JSONObject(); 
      JSONObject cube = new JSONObject(); 
      JSONObject parameters = new JSONObject(); 
      JSONObject plugin = new JSONObject(); 
      JSONObject properties = new JSONObject(); 
      JSONObject metadata = new JSONObject(); 
      JSONObject axes = new JSONObject(); 
      JSONObject details = new JSONObject(); 
      JSONObject columns = new JSONObject(); 
      JSONObject filter = new JSONObject(); 
      JSONObject rows = new JSONObject(); 
      JSONObject measures = new JSONObject(); 
      JSONObject o = new JSONObject(); 
      JSONObject hierarchies = new JSONObject(); 
      JSONObject o2 = new JSONObject(); 
      JSONObject levels = new JSONObject(); 
      JSONObject Year = new JSONObject(); 
      JSONObject cmembers = new JSONObject(); 

      cube.put("caption", null); 
      cube.put("catalog", "Global Earthquakes"); 
      cube.put("connection", "earthquakes"); 
      cube.put("name", "Earthquakes"); 
      cube.put("schema", "Global Earthquakes"); 
      cube.put("uniqueName", 
        "[earthquakes].[Global Earthquakes].[Global Earthquakes].[Earthquakes]"); 
      cube.put("visible", Boolean.FALSE); 

      properties.put("org.saiku.connection.scenario", Boolean.FALSE); 
      properties.put("org.saiku.query.explain", Boolean.TRUE); 
      properties.put("saiku.olap.query.automatic_execution", Boolean.TRUE); 
      properties.put("saiku.olap.query.drillthrough", Boolean.TRUE); 
      properties.put("saiku.olap.query.filter", Boolean.TRUE); 
      properties.put("saiku.olap.query.nonempty", Boolean.TRUE); 
      properties.put("saiku.olap.query.nonempty.columns", Boolean.TRUE); 
      properties.put("saiku.olap.query.nonempty.rows", Boolean.TRUE); 
      properties.put("saiku.olap.result.formatter", "flattened"); 
      properties.put("saiku.ui.render.mode", "table"); 


      List<String> a = new ArrayList<String>(); 
      List<String> ab = new ArrayList<String>(); 

      querymodel.put("axes", axes); 
      querymodel.put("calculatedMeasures", a); 
      querymodel.put("calculatedMembers", ab); 
      querymodel.put("details", details); 
      querymodel.put("lowestLevelsOnly", Boolean.FALSE); 
      querymodel.put("visualTotals", Boolean.FALSE); 
      querymodel.put("visualTotalsPattern", null); 

      axes.put("COLUMNS", columns); 
      axes.put("FILTER", filter); 
      axes.put("ROWS", rows); 

      List<Object> oa = new ArrayList<Object>(); 
      oa.add(o); 
      o.put("name", "Average Magnitude"); 
      o.put("type", "EXACT"); 

      details.put("axis", "COLUMNS"); 
      details.put("location", "BOTTOM"); 
      details.put("measures", oa); 

      List<String> b = new ArrayList<String>(); 
      List<String> bb = new ArrayList<String>(); 
      List<String> bc = new ArrayList<String>(); 

      columns.put("aggregators", b); 
      columns.put("filters", bb); 
      columns.put("hierarchies", bc); 
      columns.put("hierarchizeMode", null); 
      columns.put("location", "COLUMNS"); 
      columns.put("mdx", null); 
      columns.put("nonEmpty", Boolean.TRUE); 
      columns.put("sortEvaluationLiteral", null); 
      columns.put("sortOrder", null); 

      List<String> c = new ArrayList<String>(); 
      List<String> cb = new ArrayList<String>(); 
      List<String> cc = new ArrayList<String>(); 

      filter.put("aggregators", c); 
      filter.put("filters", cb); 
      filter.put("hierarchies", cc); 
      filter.put("hierarchizeMode", null); 
      filter.put("location", "FILTER"); 
      filter.put("mdx", null); 
      filter.put("nonEmpty", Boolean.TRUE); 
      filter.put("sortEvaluationLiteral", null); 
      filter.put("sortOrder", null); 

      List<String> d = new ArrayList<String>(); 
      List<String> db = new ArrayList<String>(); 
      List<Object> o2a = new ArrayList<Object>(); 
      o2a.add(o2); 
      o2.put("cmembers", cmembers); 
      o2.put("levels", levels); 
      o2.put("name", "[Date].[Time]"); 

      rows.put("aggregators", d); 
      rows.put("filters", db); 
      rows.put("hierarchies", o2a); 
      rows.put("hierarchizeMode", null); 
      rows.put("location", "ROWS"); 
      rows.put("mdx", null); 
      rows.put("nonEmpty", Boolean.TRUE); 
      rows.put("sortEvaluationLiteral", null); 
      rows.put("sortOrder", null); 

      //hierarchies.put("0", o2a); 

      levels.put("Year", Year); 

      Year.put("name", "Year"); 

      object.put("cube", cube); 
      object.put("mdx", null); 
      object.put("metadata", metadata); 
      object.put("name", "earth"); 
      object.put("parameters", parameters); 
      object.put("plugins", plugin); 
      object.put("properties", properties); 
      object.put("queryModel", querymodel); 
      object.put("queryType", "OLAP"); 
      object.put("type", "QUERYMODEL"); 

      System.out.println("++++++++++++++++++++++++++++"+object.toString()); 

      Response execute = Jsoup 
        .connect(
          "http://localhost:8080/saiku/rest/saiku/api/query/execute/") 
        .header("Content-Type", "application/json") 
        .header("Accept", "application/json") 
        .requestBody(object.toJSONString()) 
        .data(object) 
        .ignoreContentType(true) 
        .referrer("http://localhost:8080/") 
        .cookie("JSESSIONID", res.cookie("JSESSIONID")) 
        .userAgent(
          "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.94 Safari/537.36") 
        .method(Method.POST).timeout(10000).execute(); 
      System.out.println("post successfully....." 
        + object.toJSONString()); 

回答

0

你,你要发送MDX放慢参数为空