Forums

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

how to read JSON request body inside a jira REST plugin?

Satish Mogasati
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 3, 2018

I am trying to build a REST module to make some updates to JIRA issues.  My requirement is to read a user submitted json file inside my jira plugin using the rest module. I am not sure if there is any inbuilt class I can use as I tried to read using the request.getReader() and I am getting exception.

1 answer

0 votes
Alexey Matveev
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.
April 3, 2018

I know 2 ways to do it:

1. If you pass the json as a string then you can read it with the Gson library. There is usually a dependency for Gson library by default. 

You can create necessary classes, which represent the structure for you Json, and then deserialize the json string into the classes

2. Or you can pass the class, which represents the json structure, to the rest endpoint as a parameter and JSON will be deserialized automatically to the class.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events