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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Wednesday in Jira

Join our webinar: How 1B+ feature flag events helped us build the new Jira

Every time you release software, there's a bit of risk – that there's a bug, that something breaks, or that the feature doesn't resonate with customers. Feature flagging helps make high stakes s...

93 views 0 1
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