Forums

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

Jira API JQL Search for issues -result: only of specific issuetype

KerKla July 25, 2019

I'm using the Jira Rest API to get issues a user can access. My goal is to limit the requested issues to the ones I need only. I only need Sub-Tasks which have an issuetype-id of 8.

Is there a possibility to limit the response to only provide issues with this issuetype-id (or name)?

 

This is my request so far

/rest/api/2/search?jql=assignee=currentuser()&fields=key,id,issuetype,project,subtasks,summary,status

(using Basic Authentication) which is working fine.

 

The Response looks like this:

{
"expand": "schema,names",
"startAt": 0,
"maxResults": 50,
"total": 42,
"issues": [
{
"expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
"id": "---",
"self": "...",
"key": "PROJECT-NR",
"fields": {
"summary": "TaskSummary",
"issuetype": {
"self": ".../rest/api/2/issuetype/8",
"id": "8",
"description": "The sub-task of the issue (IT)",
"iconUrl": "...avatarType=issuetype",
"name": "Sub-Task",
"subtask": true,
"avatarId": 14546
},
"project": {...},
"subtasks": [],
"status": {...}
}
}
},
{[...]

and so on...

 

Appreciate every help, thank you very much! :)

2 answers

0 votes
Sobhan Alimardani
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!
June 18, 2024

Hi,
for this api you can use below filter for status or type of issue:

 

rest/api/2/search?jql=issuetype+in+(Bug,+Epic)+AND+status+=+In Progress 

and for pagination or improve your performance you can use maxResult and page at end of the url param

0 votes
Nir Haimov
Community Champion
July 25, 2019

Hi,
you can filter your search by issuetype name, not id.

Your request should be:

/rest/api/2/search?jql=assignee=currentuser%28%29%20AND%20issuetype=Sub-task&fields=key,id,issuetype,project,subtasks,summary,status
KerKla July 25, 2019

Unfortunately I still get issues with other types (Task, Test, ...) with this request

Nir Haimov
Community Champion
July 25, 2019

Did my line worked for you (for Sub-task)?

What is the error you get, it should work for any issue type.
of course if you want to filter multiple issue types at once, it should be:

/rest/api/2/search?jql=assignee=currentuser() AND issuetype in (Sub-task, task, test)&fields=key,id,issuetype,project,subtasks,summary,status
KerKla July 25, 2019

I didn't get an error, I just still get all issues but I only want to get sub-tasks.
I know I could filter them programmatically but I want to increase the performance of my application so I want to limit the results of my requests to what I really need. If there is no solution to do this, I will filter it programmatically but if there is that would be great :)

/rest/api/2/search?jql=assignee=currentuser()&issuetype=Sub-task&fields=key,id,issuetype,project,subtasks,summary,status

This is the request I sent...

Nir Haimov
Community Champion
July 25, 2019

This is the way to get it filtered and not getting all issues...

It sounds weird you get all issues on and not only Sub-tasks (for me it works fine)

Patrick Joerg
Contributor
July 7, 2020

Isn't there a flag that makes a Subtask a Subtask? I mean even if its name is different?

I can't remember where that is, but I remember having seen that.

So maybe all of your tasks are marked as Subtasks, then it would make sense.

Suggest an answer

Log in or Sign up to answer