Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to fix org.codehaus.jettison.json.JSONException: A JSONObject text must begin with '{' at charac

Emilia Traczyk February 16, 2023

When I try to create an issue

 issueClient.createIssue(newIssue.build()).claim().getKey();

I get 

org.codehaus.jettison.json.JSONException: A JSONObject text must begin with '{' at character

How can I deal with that?

1 answer

1 accepted

0 votes
Answer accepted
Prince Nyeche
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.
February 16, 2023

The error seems to be clear. You are sending a wrong data object to that API. The JSON object isn't formatted properly. You need to get that checked.

Emilia Traczyk February 17, 2023

I send via postaman: 

 

{
    "fields": {
       "project":
       {
          "key""TEST"
       },
       "summary""REST ye merry gentlemen.",
       "description": {
           "type" : "doc",
           "version" : 1,
           "content" : [
               {
                   "type" : "paragraph",
                   "content" : [
                       {
                           "type" : "text",
                           "text" : "description"
                       }
                   ]
               }

           ]
       },
       "issuetype": {
          "issuetype"1
       }
   }
}

 and as IssueInput I get:

 

IssueInput{fields={summary=FieldInput{id=summary, value=REST ye merry gentlemen.}, issuetype=FieldInput{id=issuetype, value=ComplexIssueInputFieldValue{valuesMap={id=1}}}, project=FieldInput{id=project, value=ComplexIssueInputFieldValue{valuesMap={key=TEST}}}}}

when I execute 

issueClient.createIssue(input).claim().getKey();

I get:

 

org.codehaus.jettison.json.JSONException: A JSONObject text must begin with '{' at character 1 of <?xml version="1.0" encoding="UTF-8" standalone="yes"?><status><status-code>404</status-code><message>null for uri: https://ocadotech.atlassian.net/rest/api/3/rest/api/latest/issue</message></status>

 

I do think I have correct json, but if I'm wrong please correct me.

Prince Nyeche
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.
February 18, 2023

Your JSON data seems valid, I'm not sure what might be wrong here. If you're sending via postman probably you want to confirm that the URL you're sending to is actually the right one and also if there's any additional data that is being passed along with your request via the postman.

Emilia Traczyk February 23, 2023

I solved the issue using the feign client.

Megha Banihall
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!
April 12, 2023

Hi @Emilia Traczyk , I am also facing same issue...could you please share the solution?
How did you get it working?

Thanks!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events