org.codehaus.jettison.json.JSONException: JSONObject["fields"] not found.

July 9, 2018

When I use   com.atlassian.jira:jira-rest-java-client-core:5.0.4 to get issue transitions.

The client report exception:

Caused by: org.codehaus.jettison.json.JSONException: JSONObject["fields"] not found. at org.codehaus.jettison.json.JSONObject.get(JSONObject.java:360) 

at org.codehaus.jettison.json.JSONObject.getJSONObject(JSONObject.java:454)

at com.atlassian.jira.rest.client.internal.json.TransitionJsonParserV5.parse(TransitionJsonParserV5.java:33)

 My jira server is Jira (v6.4.7#64022-sha1:4cb2968)

1 answer

0 votes
Kirubel Tesfaye
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 9, 2018

Hi @雷,

The exception indicate that you are trying to access JSONObject property called "fields". This might be caused if your rest response doesn't have a property named fields.

Before accessing the JSON object check the response status code. If it is different from 200, the rest response don't have fields, instead it tries to tell you that some form of error has occurred in the response.

 

Hope this helps!

July 9, 2018

But ,why jira-rest-java-client-core has this bug? how to I report to fix it ?

Kirubel Tesfaye
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 9, 2018

Hello again,

I don't think that this is a bug in jira-rest-java-client, it is simply a GIGO(Garbage In Garbage Out) principle. If you give a bad request to jira rest api, It will give you incorrect result.

July 10, 2018

Thanks reply.

But, my jira server returned  json doesn't contains the "field" .

WX20180710-175701@2x.png

Kirubel Tesfaye
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 10, 2018

Could you show me your query Url?

like

https://localhost:8080/rest/api/2 + your query parameter

July 10, 2018

/rest/api/2/issue/11282/transitions

Kirubel Tesfaye
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 11, 2018

Hello again @雷,

Sorry for the late reply. I have seen your query parameter and what I observed is that you didn't use expand parameter.

You should append &expand=transitions.fields to your query parameter.

Hope this helps!

Like Markus Mitterauer likes this
July 13, 2018

Oh, I know it. Thanks.

Lord Aragorn
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 13, 2023

I am also getting same error. However, I am using jql and in code I am getting the error. How to include expand in it. expand is not available in jql.

Like Tina likes this
Tina May 12, 2024

@Lord Aragorn Did you fix this? I have the same issue.

Suggest an answer

Log in or Sign up to answer