taskadapter / redmine-java-api

Redmine Java API
Apache License 2.0
269 stars 162 forks source link

Error Get Issue #270

Closed oscarivn closed 8 years ago

oscarivn commented 8 years ago

Version Redmine 3.3.0 Version API JAVA Version 3.0.0 (August 15, 2016) Issue related #234

/-------------------------- Getting an Issue by ID --------------------------/ String uri = "http://redmine.test.com/redmine"; String apiAccessKey= "testapikey1234567890"; Integer queryId = 12345;

RedmineManager mgr = RedmineManagerFactory.createWithApiKey(uri,apiAccessKey);//OK IssueManager issueManager = mgr.getIssueManager();//OK Issue SingleIssue = issueManager.getIssueById(queryId);//ERROR

/------------------------------------------------------------------------------------------------------------------ The code debugging returns a JSON structure well formed from the server, but when is parsing to return the object is when i have this log. ------------------------------------------------------------------------------------------------------------------/ Exception in thread "main" com.taskadapter.redmineapi.RedmineFormatException: org.json.JSONException: JSONObject["issue"] not found. at com.taskadapter.redmineapi.internal.Transport.parseResponse(Transport.java:598) at com.taskadapter.redmineapi.internal.Transport.getObject(Transport.java:355) at com.taskadapter.redmineapi.internal.Transport.getObject(Transport.java:431) at com.taskadapter.redmineapi.IssueManager.getIssueById(IssueManager.java:127) at com.grupoassa.redmine.RedMine.main(RedMine.java:26) Caused by: org.json.JSONException: JSONObject["issue"] not found. at org.json.JSONObject.get(JSONObject.java:498) at org.json.JSONObject.getJSONObject(JSONObject.java:592) at com.taskadapter.redmineapi.internal.json.JsonInput.getObjectNotNull(JsonInput.java:344) at com.taskadapter.redmineapi.internal.RedmineJSONParser.getResponseSingleObject(RedmineJSONParser.java:535) at com.taskadapter.redmineapi.internal.Transport.parseResponse(Transport.java:596) ... 4 more

alexeyOnGitHub commented 8 years ago

"Get issue by ID" requires issue ID. You are providing query id in your example.

The code should throw a different exception when issue is not found though.

oscarivn commented 8 years ago

Hi Alexey.

In my example "queryID" is just the name of the variable, is an integer and in fact is a valid Issue ID . I got a good Json response (debugging) but in the parsing step to return the final value it fails.

oscarivn commented 8 years ago

In my example "queryID" is just the name of the variable, is an integer and in fact is a valid IssueID . I got a good Json response (debugging) but in the parsing step to return the final value it fails.

alexeyOnGitHub commented 8 years ago

can you paste the full json response?

oscarivn commented 8 years ago

{"start_date":"2016/05/04","estimated_hours":null,"priority_id":4,"created_on":"2016/05/04 13:53:45 -0300","project_id":54,"root_id":12596,"lock_version":8,"lft":1,"fixed_version_id":null,"updated_on":"2016/05/09 15:22:40 -0300","subject":"Interfaz INT-0011 PIC001 LockDocument ","id":12596,"done_ratio":70,"assigned_to_id":663,"tracker_id":55,"category_id":null,"parent_id":null,"due_date":"2016/05/04","status_id":65,"description":"Creaci\u00f3n de INT para consulta de bloqueos de cuenta\r\n","author_id":597,"rgt":2}

alexeyOnGitHub commented 8 years ago

here is a sample valid json received in an integration test:

{"issue":{"id":12055,"project":{"id":3227,"name":"test project"},"tracker":{"id":1,"name":"Bug"},"status":{"id":1,"name":"New"},"priority":{"id":2,"name":"Normal"},"author":{"id":1,"name":"Redmine Admin"},"subject":"some issue 0 Wed Aug 24 13:31:20 PDT 2016","start_date":"2016-08-24","done_ratio":0,"spent_hours":0.0,"total_spent_hours":0.0,"custom_fields":[{"id":1,"name":"my_custom_1","value":""},{"id":2,"name":"custom_boolean_1","value":"0"},{"id":3,"name":"custom_multi_list","multiple":true,"value":["V2"]}],"created_on":"2016-08-24T20:31:23Z","updated_on":"2016-08-24T20:31:23Z"}}

do you have the release version of Redmine 3.3.0 or some pre-release / custom one? do you have any custom plugins installed that would change the standard REST response?

oscarivn commented 8 years ago

Hi Alexey.

Your format is very different and more complete. I can see the first string "issue" and my json response have no that string and is because of that it is failing. Our redmine v3.3.0 is a released and stable version and we have no additional plug in. I tried directly in the browser and the result is the same for JSON, but the content looks good in XML format. Is there any way to use the API for XML format(as workaround)?

oscarivn commented 8 years ago

The IT team told us they had a little mistake and our redmine version is v1.0.1 (I know, very sad). I'm sure this is the problem. My last question would only be, the API has the capability to use XML format?

Thank you.

alexeyOnGitHub commented 8 years ago

hi. the current version does not support xml. it used to a while back but I switched to json.