java - Caused by: com.google.gson.stream.MalformedJsonException: Expected EOF at line 1 column 21 -
i trying run sample java program retrieve top 5 defects rally. getting following error:
querying top 5 highest priority unfixed defects... exception in thread "main" com.google.gson.jsonsyntaxexception: com.google.gson.stream.malformedjsonexception: expected eof @ line 1 column 21 @ com.google.gson.jsonparser.parse(jsonparser.java:65) @ com.google.gson.jsonparser.parse(jsonparser.java:45) @ com.rallydev.rest.response.response.(response.java:25) @ com.rallydev.rest.response.queryresponse.(queryresponse.java:16) @ com.rallydev.rest.rallyrestapi.query(rallyrestapi.java:179) @ queryexample.main(queryexample.java:36) caused by: com.google.gson.stream.malformedjsonexception: expected eof @ line 1 column 21 @ com.google.gson.stream.jsonreader.syntaxerror(jsonreader.java:1298) @ com.google.gson.stream.jsonreader.peek(jsonreader.java:390) @ com.google.gson.jsonparser.parse(jsonparser.java:60) ... 5 more
the source code listed below:
import com.google.gson.jsonelement; import com.google.gson.jsonobject; import com.rallydev.rest.rallyrestapi; import com.rallydev.rest.request.queryrequest; import com.rallydev.rest.response.queryresponse; import com.rallydev.rest.util.fetch; import com.rallydev.rest.util.queryfilter; import java.io.ioexception; import java.net.uri; import java.net.urisyntaxexception; public class queryexample { public static void main(string[] args) throws urisyntaxexception, ioexception { //create , configure new instance of rallyrestapi rallyrestapi restapi = new rallyrestapi(new uri("https://rally1.rallydev.com/#/4608446320ud"), "stephen5@netapp.com", "password"); restapi.setapplicationname("queryexample"); try { system.out.println("querying top 5 highest priority unfixed defects..."); queryrequest defects = new queryrequest("defect"); defects.setfetch(new fetch("formattedid", "name", "state", "priority")); defects.setqueryfilter(new queryfilter("state", "<", "fixed")); defects.setorder("priority asc,formattedid asc"); //return 5, 1 per page defects.setpagesize(1); defects.setlimit(5); queryresponse queryresponse = restapi.query(defects); if (queryresponse.wassuccessful()) { system.out.println(string.format("\ntotal results: %d", queryresponse.gettotalresultcount())); system.out.println("top 5:"); (jsonelement result : queryresponse.getresults()) { jsonobject defect = result.getasjsonobject(); system.out.println(string.format("\t%s - %s: priority=%s, state=%s", defect.get("formattedid").getasstring(), defect.get("name").getasstring(), defect.get("priority").getasstring(), defect.get("state").getasstring())); } } else { system.err.println("the following errors occurred: "); (string err : queryresponse.geterrors()) { system.err.println("\t" + err); } } } { //release resources restapi.close(); } } }
any on what's causing appreciated!
looking @ code think url:
uri("https://rally1.rallydev.com/#/4608446320ud")
is problem, needs just:
uri("https://rally1.rallydev.com")
.
rally rest url's of form:
https://rally1.rallydev.com/slm/webservice/1.43/defect/12345678910.js
so when java rest library trying formulate query against url built code, end looking this:
https://rally1.rallydev.com/#/4608446320ud/slm/webservice/1.43/defect/12345678910.js
if plug browser you'll rally 404, contains lot of html , formatting, not json. "#/4608446320ud" string used in rallyui , provides project scoping information in app. ui-context explains why formatted html 404 response java toolkit didn't know how handle.
Comments
Post a Comment