The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

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

How to get a customized JSON from the rest-api?

Deleted user
December 6, 2017

I am using Jira cloud and thus I couldn't get the REST API Browser add on to develop my query. 

I had created another question, but it was flagged as SPAM because I tried to insert the original answer I found here to bestow credit where credit is due.

 

I have found on google the following very nice jql that returns all the epics from a given project.

/jira/rest/api/2/search?jql=project%3D%22Project%20Name%22%20AND%20issuetype%3D%22Epic%22&fields=summary,duedate,priority,issuetype,key,timeoriginalestimate,customfield_11000,customfield_10100,customfield_10002,customfield_10014,assignee,components,fixVersions,versions,resolution,customfield_10011,labels,reporter,status,customfield_10015,time estimate

 

I'm doing a trial and error approach to get something like the JSON structure bellow, my current iteration is:

 

/search?jql=project%3D%22<project-name>%22%20AND%20issuetype%3D%22Epic%22&fields=summary,customfield_11000,customfield_10100,customfield_10014

 

{[
epics: [
epic: [
name: epicName,
epicId: epicID,
url: epicURL,
sprints: [
sprint: [
name: sprintName,
sprintId: sprintID,
url: sprintURL.
stories: [
story: [
name: storyName,
storyId: storyID,
url: storyURL,
issues : [
id: issueId,
url: issueUrl,
type: issueType,
name: issueName,
status: issueStatus
]
]
]
]
]
]}

 

Thanks in advance

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

1 vote
Answer accepted
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 Champions.
December 6, 2017

Hello,

Rest api method returns JSON in the format which was designed to be returned. You can not make a Rest Api method return a different JSON

Deleted user
December 6, 2017

OK, Thanks for the input!

So I would need to have one JQL search for the epics.

Then, for each epic get all the sprints.

Then, for each sprint get all the stories.

And, finally, for each story get all the issues.

 

Is that it?

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 Champions.
December 6, 2017

You can actually get epics, stories and issues in one Rest Api Call to /jira/rest/api/2/search. Then you can work on the received json and get all data you need. Sprint is just a cutsom field. Epic Link is also a custom field. Stories connected to issues by links. You can get all the information from the return JSON and process it.

TAGS
AUG Leaders

Atlassian Community Events