Redmine Java API: getIssueById returns corrupt JSON?
Added by Sarah Steffen over 12 years ago
Hi,
I am trying to push tickets from a Lotus Notes Database into Redmine as issues. Therefore I wrote a Java Agent using redmine-java-api-1.19.jar. Creating new issues based on my Notes documents works fine. If I try to update an existing issue in Redmine, however, the RedmineManager throws a RedmineFormatException.
My code:
Issue issueToUpdate = mgr.getIssueById(someIntegerValue);
issueToUpdate.setSubject("something");
// set all the other fields needed
mgr.update(issueToUpdate);
But the exception already occurs at the first line (the given issue ID is correct and it definitely is an Integer type, I double-triple-etc-checked that. I can open the issue in the browser without any problems):
com.taskadapter.redmineapi.RedmineFormatException: org.json.JSONException: A JSONObject text must begin with '{' at 1 [character 2 line 1]
at com.taskadapter.redmineapi.internal.Transport.parseResponse(Transport.java:534)
at com.taskadapter.redmineapi.internal.Transport.getObject(Transport.java:316)
at com.taskadapter.redmineapi.internal.Transport.getObject(Transport.java:375)
at com.taskadapter.redmineapi.RedmineManager.getIssueById(RedmineManager.java:236)
at JavaAgent.saveIssueToRedmine(Unknown Source)
at JavaAgent.pushIssueFromNotesToRedmine(Unknown Source)
at JavaAgent.NotesMain(Unknown Source)
at lotus.domino.AgentBase.runNotes(Unknown Source)
at lotus.domino.NotesThread.run(Unknown Source)
Caused by: org.json.JSONException: A JSONObject text must begin with '{' at 1 [character 2 line 1]
at org.json.JSONTokener.syntaxError(JSONTokener.java:433)
at org.json.JSONObject.<init>(JSONObject.java:188)
at org.json.JSONObject.<init>(JSONObject.java:314)
at com.taskadapter.redmineapi.internal.RedmineJSONParser.getResponseSingleObject(RedmineJSONParser.java:692)
at com.taskadapter.redmineapi.internal.Transport.parseResponse(Transport.java:532)
... 8 more
I use one custom field into which I put a simple string consisting of numbers and capital letters. No special or reserved characters are used in any field of the issue (as I said, I can open it just fine in Redmine itself), so I am a bit stuck here trying to find out why the JSON-text turns out corrupted. Is there a way to actually see the JSON text the Manager tries to parse? Or might the error be caused by something completely different?
This is the environment used:
Environment:
Redmine version 2.2.2.stable
Ruby version 1.9.3 (x86_64-linux)
Rails version 3.2.11
Environment production
Database adapter Mysql2
Redmine plugins:
redmine_backlogs v0.9.38
I tried it with Redmine Java API 1.18 and 1.19 (same results)
Thanks in advance,
Sarah
EDIT:
I can still retrieve the list of all issues as a JSON object with http:// ... /redmine/issues.json, even the text for the issue that caused the exception mentioned above is correct:
{
"id": 88,
"project": {
"id": 7,
"name": "Test Lotus Connector"
},
"tracker": {
"id": 1,
"name": "Fix"
},
"status": {
"id": 2,
"name": "In Progress"
},
"priority": {
"id": 2,
"name": "Middle"
},
"author": {
"id": 12,
"name": "Sarah Steffen"
},
"assigned_to": {
"id": 9,
"name": "Sarah Steffen"
},
"fixed_version": {
"id": 2,
"name": "1"
},
"subject": "Test ABC",
"description": "bla bla bla 123",
"done_ratio": 0,
"custom_fields": [
{
"id": 2,
"name": "SPR no",
"value": "SSTN96MCFK"
},
{
"id": 1,
"name": "Solution",
"value": ""
},
{
"id": 3,
"name": "Tested by Person 1"
},
{
"id": 4,
"name": "Tested by Person 2"
},
{
"id": 5,
"name": "Release",
"value": ""
},
{
"id": 7,
"name": "Product Area",
"value": ""
},
{
"id": 8,
"name": "Tech Area",
"value": ""
},
{
"id": 9,
"name": "Platform",
"value": ""
}
],
"created_on": "2013-04-11T10:08:43Z",
"updated_on": "2013-04-15T07:37:39Z",
"story_points": 1
},
http:// ... /redmine/issues/88.json though returns http error 500. Why?
Replies (1)
RE: Redmine Java API: getIssueById returns corrupt JSON?
-
Added by Andi Online almost 12 years ago
Same error here! Did you find a way to resolve the issue?