Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Jira API call is failing

Jira API call is failing due to some special characters like (double quote, dot .... etc)
below is the exception captured in the logs.

Exception while posting to Jira: Jira exception [{"errorMessages":["Unexpected character ('\"' (code 34)): was expecting comma to separate OBJECT entries\n at [Source: org.apache.catalina.connector.CoyoteInputStream@78d2c46f; line: 1, column: 160]"]}]

can any one share the list of such character?

5 answers

In your post you have only copied the first line of your error.

org.apache.catalina.connector.CoyoteInputStream

Tomcat should not have any knowledge of whether the JSON object is valid or not, or if it is even JSON. The Content Type and Accepts headers are used in MIME mapping.

At this point it is a call the text is just characters.

Characters in the URL can be managed from the server.xml

<Connector connectionTimeout="20000"
port="8080"
protocol="HTTP/1.1"
redirectPort="8443"
relaxedQueryChars='^{}[]|&quot;' />

In your error there is a hint `was expecting comma to separate OBJECT entries`
As you are using a POST this implies the JSON in the body of your REST call is not valid.

As @Davin Studer has mentioned use a JSON library such as Jackson or GSON

Never serialise objects using string manipulation. It will always come back and bite you.

Libraries have the ability to configure de/serialization.

The following is just an example of the many configuration properties for Jackson

mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

Can you get hold of the payload in your POST? If so check it in an online JSON parser.

This is just one of many online tools.

@Sudhansu Sekhar Panda did you manage to solve your issue?

Please update the people who were so kind as to take a few minutes out of their day to assist you.

Currently we are still working on it. I will share the update. Once everything is fixed.

But any ways thanks a lot for your support guys

Are you building the JSON manually? If so I would suggest creating a object to represent your data and then use one of the many libraries out there to serialize it to JSON.

@Sudhansu Sekhar Panda ,

I'm guessing that the error is happening in Json that you're passing to a POST call, and not happening in the syntax of the URI.  If it is in the URI, then that's another answer.

What I'd do first is to look at your Json and go to line 1 column 160.  If it looks like there's a special character there, then escape it.

(I don't know if it's the same for you, but at the company where I work, they block the site linked to in the previous comment.  So, I'm not sure what it says there.)

Generally, you can escape a special character with a backslash \

For example:  \" lets you have a double quote " where you may be getting the error.

In summary:

  1. Find the character causing the trouble
  2. Escape the character

I have a list of problematic characters that I search for and escape before sending a POST call.  This usually covers the problem areas, but there may be more:

  • \  -> \\
  • '  ->  \'
  • any kind of new line character  ->  \n
  • tab  ->  \t
  • weird characters that come up that are not needed  ->  zero length string ""

You don't want to replace all double quotes (if those are the problem) in the Json with \", though, since they're needed for the Json structure.  Make sure you escape only in the values (of the key:value pairs) before forming the Json.

Hi @Sudhansu Sekhar Panda this is problem with JSON format, so this link should give you your answer https://www.tutorialspoint.com/json_simple/json_simple_escape_characters.htm

Hi,

I have the same problem. I'm escaping the double quotes within the JSON with \" but had still the same error.

I tried with  a very simple json containg in the description of an issue just one double quoute and is not working.

My goal is to have a HTML page in the description of an issue created by the API, but I'm stuck now in this problem when escaping the double quotes.

Does anyone has a solution ?

Regards

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you