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 vote
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 Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Tuesday in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

246 views 1 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