java - Error while posting JSON using JSOUP concept -
i want post nested json input saiku server.i got successful in postman while trying in java code have error such as
errorjava.lang.illegalargumentexception: data value must not null
below code posting nested json saiku server.
// 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> = 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, gecko) chrome/50.0.2661.94 safari/537.36") .method(method.post).timeout(10000).execute(); system.out.println("post successfully....." + object.tojsonstring());
you're mdx paramter you're sending null
Comments
Post a Comment