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

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

1 votes
Alexey Matveev Community Champion Dec 06, 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

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 Community Champion Dec 06, 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.

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,003 views 12 18
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot